' . $c_r_id; } $branch_id = $_GET['b']; if (!empty($_GET['b'])) { $branch_id = $_GET['b']; if (!is_numeric($branch_id)) { $branch_id = 1; } } else { $branch_id = 1; } if (!empty($_GET['f'])) { if (is_numeric($c_r_id) && $_GET['f'] == 1) { $branch_id = 1; } } $branch_sql = '=' . $branch_id; if ($branch_id == 1) { $branch_sql = '<>' . $branch_id; } $error = 0; $data = array( 'totals' => array( 'inv' => 0, 'bonds' => 0, ) ); $get_invoices_sql = mysqli_query($db, "SELECT `r_month_user_invoices`.`filter`, `r_month_user_invoices`.`total`, `r_month_user_invoices`.`invoices_status_id`, `r_month_user_invoices`.`how_pay_id`, DATE_FORMAT(`r_month_user_invoices`.`filter`, '%Y-%m') AS `ddss` FROM `r_month_user_invoices` INNER JOIN `branch` ON `branch`.`id` = `r_month_user_invoices`.`branch_id` WHERE DATE_FORMAT(`r_month_user_invoices`.`filter`, '%Y-%m') <= '$today' AND `r_month_user_invoices`.`branch_id` $branch_sql AND `branch`.`commercial_register_id` $c_r_id_sql AND `branch`.`commercial_register_id` <> 5 "); if (mysqli_num_rows($get_invoices_sql) > 0) { while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) { switch ($get_invoices['invoices_status_id']) { case '1': case '2': switch ($get_invoices['how_pay_id']) { case '3': case '4': if($get_invoices['ddss'] < $today) { $data['totals']['inv'] += $get_invoices['total']; } else { $data['inv'][$get_invoices['filter']]['stuck'] += $get_invoices['total']; } break; } break; case '3': switch ($get_invoices['how_pay_id']) { case '3': case '4': if($get_invoices['ddss'] < $today) { $data['totals']['bonds'] += $get_invoices['total']; } else { $data['bonds'][$get_invoices['filter']]['plus'] += $get_invoices['total']; } break; } break; default: $error++; break; } } } $get_invoices_sql = mysqli_query($db, "SELECT `r_month_user_bonds`.`filter`, `r_month_user_bonds`.`total`, `r_month_user_bonds`.`bonds_status_id`, `r_month_user_bonds`.`how_pay_id`, DATE_FORMAT(`r_month_user_bonds`.`filter`, '%Y-%m') AS `ddss` FROM `r_month_user_bonds` INNER JOIN `branch` ON `branch`.`id` = `r_month_user_bonds`.`branch_id` WHERE DATE_FORMAT(`r_month_user_bonds`.`filter`, '%Y-%m') <= '$today' AND `r_month_user_bonds`.`branch_id` $branch_sql AND `branch`.`commercial_register_id` $c_r_id_sql AND `branch`.`commercial_register_id` <> 5 "); if (mysqli_num_rows($get_invoices_sql) > 0) { while ($get_invoices = mysqli_fetch_assoc($get_invoices_sql)) { switch ($get_invoices['bonds_status_id']) { case '1': case '2': switch ($get_invoices['how_pay_id']) { case '1': case '2': case '3': case '4': case '6': case '7': case '8': case '9': case '10': if($get_invoices['ddss'] < $today) { $data['totals']['bonds'] += $get_invoices['total']; } else { $data['bonds'][$get_invoices['filter']]['plus'] += $get_invoices['total']; } break; } break; case '3': switch ($get_invoices['how_pay_id']) { case '1': case '2': case '5': if($get_invoices['ddss'] < $today) { $data['totals']['inv'] += $get_invoices['total']; } else { $data['inv'][$get_invoices['filter']]['stuck'] += $get_invoices['total']; } break; } break; default: $error++; break; } } } $totals = ($data['totals']['bonds'] - $data['totals']['inv']); ?>

إيرادات شهر

-
+
طلب التقرير
رصيد العملاء
التاريخ وارد صادر الرصيد