示例#1
0
 public static function CreateCashCreditNote($client, $invoice, $credit, $description)
 {
     //Called and stored in a session object
     try {
         $datetime = new DateTime();
         $sql = 'INSERT INTO credit_notes (client_id, invoice_id, description, datetime, stamp, status) VALUES (' . $client->id . ', ' . $invoice . ', "' . $description . '", "' . $datetime->format('d/m/Y H:i a') . '", ' . $datetime->format('YmdHis') . ', 0)';
         DatabaseHandler::Execute($sql);
         $sql = 'SELECT * FROM credit_notes WHERE stamp = ' . $datetime->format('YmdHis');
         $res = DatabaseHandler::GetRow($sql);
         $crnote = new CreditNote($res['id'], $res['invoice_id'], $res['description'], $res['datetime'], $res['status'], $client);
         $crnote->addLineItem(CreditNoteLine::Create($crnote->id, 'Credit Note', 'General credit', 1, floatval($credit), 0));
         $crnote->origInvoice = $invoice;
         return $crnote;
     } catch (Exception $e) {
         return false;
     }
 }