Вот мой код .... и мои сомнения вместе с кодом См. В функции toltalRetailerComm($userId)
... Я получаю значение
$ shoppeId
и
$ storeId
, и эту же переменную можно использовать в следующей функции retailerDailyComm($userId, $fromDate, $toDate)
, используя таким образом функцию retailerDailyComm($shoppeId,$storeId, $fromDate, $toDate)
function toltalRetailerComm($userId) {
$sql = "SELECT shoppe_id FROM atm_super_shoppe WHERE user_id='$userId'";
$shoppe_query = $this->db->query($sql);
$sql = "SELECT shoppe_id FROM atm_store WHERE user_id='$userId'";
$store_query = $this->db->query($sql);
if ($shoppe_query->num_rows() > 0) {
$result = $shoppe_query->row();
$shoppeId = $result->shoppe_id;
$sql = "SELECT COALESCE(sum(commission),0) as commission FROM atm_shoppe_commission WHERE shoppe_id ='$shoppeId'";
//$sql = "SELECT commission FROM atm_shoppe_commission WHERE shoppe_id='$shoppeId ' BETWEEN '03-5-2011' AND '05-5-2011'";
$query = $this->db->query($sql);
print_r($shoppeId);
if ($query->num_rows > 0) {
$result = $query->row();
$commission = $result->commission;
return $commission;
}
} else
if ($store_query->num_rows() > 0) {
$result = $store_query->row();
$storeId = $result->shoppe_id;
$sql = "SELECT COALESCE(sum(commission),0) as commission FROM atm_store_commission WHERE shoppe_id ='$storeId'";
//$sql = "SELECT commission FROM atm_store_commission WHERE shoppe_id='$storeId ' BETWEEN '03-5-2011' AND '05-5-2011'";
$query = $this->db->query($sql);
print_r($storeId);
if ($query->num_rows > 0) {
$result = $query->row();
$commission = $result->commission;
return $commission;
}
}
}
/ ********** ИТОГИ КОМИССИИ ИТОГО ***************************** /
/ ********** ОБЩАЯ ЗАРЯДКА НАЧИНАЕТСЯ, ЧТО ЗАКОНЧИЛАСЬ ДАТА КОМИССИИ *****************/
function retailerDailyComm($userId, $fromDate, $toDate) {
$sql = "SELECT shoppe_id FROM atm_super_shoppe WHERE user_id='$userId'";
$shoppe_query = $this->db->query($sql);
$sql = "SELECT shoppe_id FROM atm_store WHERE user_id='$userId'";
$store_query = $this->db->query($sql);
if ($shoppe_query->num_rows() > 0) {
$result = $shoppe_query->row();
$shoppeId = $result->shoppe_id;
$sql = "SELECT commission as retailDailyCommission FROM atm_shoppe_commission WHERE shoppe_id='$shoppeId ' BETWEEN '$fromDate' AND '$toDate'";
$query = $this->db->query($sql);
if ($query->num_rows > 0) {
$result = $query->row();
$retailDailyCommission = $result->retailDailyCommission;
return $retailDailyCommission;
} else
if ($store_query->num_rows() > 0) {
$result = $store_query->row();
$storeId = $result->shoppe_id;
$sql = "SELECT commission as retailDailyCommission FROM atm_store_commission WHERE shoppe_id='$storeId' BETWEEN '$fromDate' AND '$toDate'";
$query = $this->db->query($sql);
if ($query->num_rows > 0) {
$result = $query->row();
$retailDailyCommission = $result->retailDailyCommission;
return $retailDailyCommission;
}
}
}
}