@ -99,7 +99,10 @@ class Note_model extends CI_Model {
// AND pn_memo NOT LIKE '{\"id\":\"WH-%'
$this->search = $search_sql;
// $this->orderby=" ORDER BY CASE pn.pn_send WHEN 'sendfail' THEN 1 ELSE 2 END ,pn.pn_sn DESC ";
$this->orderby=" ORDER BY CASE WHEN pn.pn_send='sendfail' AND pn.pn_payment_status COLLATE SQL_Latin1_General_CP1_CI_AS = 'Completed' THEN 1 WHEN pn.pn_send = 'sendfail' THEN 2 ELSE 9 END, pn.pn_payment_date DESC ,pn.pn_sn DESC ";
$this->orderby=" ORDER BY CASE WHEN pn.pn_send='sendfail' AND pn.pn_payment_status COLLATE SQL_Latin1_General_CP1_CI_AS = 'Completed' THEN 1
WHEN pn.pn_payment_status = 'DECLINED'
THEN 99
WHEN pn.pn_send = 'sendfail' THEN 2 ELSE 9 END, pn.pn_payment_date DESC ,pn.pn_sn DESC ";