Esempio n. 1
0
 public function definition()
 {
     $meminfo = $this->findExtraTable('meminfo');
     if ($meminfo === false) {
         return parent::definition();
     }
     return '
         SELECT
             m.card_no AS memnum,
             CASE
                 WHEN a.card_no IS NOT NULL AND b.card_no IS NOT NULL
                 THEN a.payments + b.totPayments
                 WHEN a.card_no IS NOT NULL
                 THEN a.payments
                 WHEN b.card_no IS NOT NULL
                 THEN b.totPayments
             END AS payments,
             CASE WHEN a.startdate IS NULL THEN b.startdate
                 ELSE a.startdate END AS startdate
         FROM ' . $meminfo . ' AS m 
             LEFT JOIN equity_history_sum AS a ON a.card_no=m.card_no
             LEFT JOIN stockSumToday AS b ON m.card_no=b.card_no
         WHERE a.card_no IS NOT NULL 
             OR b.card_no IS NOT NULL
     ';
 }
Esempio n. 2
0
 public function definition()
 {
     $custdata = $this->findExtraTable('custdata');
     if ($custdata === false) {
         return parent::definition();
     }
     return '
         SELECT   
             c.CardNo AS card_no,
             (CASE WHEN a.charges IS NULL THEN 0 ELSE a.charges END)
                 + (CASE WHEN t.charges IS NULL THEN 0 ELSE t.charges END)
                 AS totcharges,
             (CASE WHEN a.payments IS NULL THEN 0 ELSE a.payments END)
                 + (CASE WHEN t.payments IS NULL THEN 0 ELSE t.payments END)
                 AS totpayments,
             (CASE WHEN a.balance IS NULL THEN 0 ELSE a.balance END)
                 + (CASE WHEN t.balance IS NULL THEN 0 ELSE t.balance END)
                 AS balance,
             (CASE WHEN t.card_no IS NULL THEN 0 ELSE 1 END) AS mark
         FROM ' . $custdata . ' AS c
             LEFT JOIN ar_history_sum AS a ON c.CardNo=a.card_no AND c.personNum=1
             LEFT JOIN ar_history_today_sum AS t ON c.CardNo = t.card_no AND c.personNum=1
         WHERE c.personNum=1
     ';
 }
Esempio n. 3
0
 public function definition()
 {
     $custdata = $this->findExtraTable('custdata');
     if ($custdata === false) {
         return parent::definition();
     }
     return '
     SELECT c.CardNo, 
         CASE 
             WHEN a.balance IS NULL THEN c.ChargeLimit
             ELSE c.ChargeLimit - a.balance END
         AS availBal,
         CASE WHEN a.balance is NULL THEN 0 ELSE a.balance END AS balance,
         CASE WHEN a.mark IS NULL THEN 0 ELSE a.mark END AS mark   
     FROM ' . $custdata . ' AS c 
         LEFT JOIN ar_live_balance AS a ON c.CardNo = a.card_no
     WHERE c.personNum = 1';
 }