コード例 #1
0
//$do_company = new Company($GLOBALS['conx']);
//$do_task = new Task($GLOBALS['conx']);
//$do_task_category = new TaskCategory($GLOBALS['conx']);
//$do_contact_task = new Contact();
$invoice_access = true;
if ($invoice_access) {
    if (!is_object($_SESSION['do_invoice'])) {
        //$do_invoice = new Invoice();
        //$do_invoice->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
        echo _('Your page session has been expired. Please go back to the Invoice page and try again.');
        exit;
    }
    $do_company = new Company();
}
$RecurrentInvoice = new RecurrentInvoice();
$id_rec = $RecurrentInvoice->checkIfInvoiceIsInRecurrent($_SESSION['do_invoice']->idinvoice);
// Check if recurrent
if ($id_rec) {
    $is_recurrent = $id_rec;
    $RecurrentInvoiceCC = new RecurrentInvoiceCC();
    $id_rec_cc = $RecurrentInvoiceCC->has_cc_info($id_rec);
    //Check if having CC in DB
    if (!$id_rec_cc) {
        $id_rec_cc = 0;
    } else {
        $id_rec_cc = 1;
    }
    //idrecurrentinvoice
} else {
    $is_recurrent = 0;
    $id_rec_cc = 0;
コード例 #2
0
ファイル: .Invoice.class.php プロジェクト: jacquesbagui/ofuz
 /**
  * Method to send the email
  * @param $idinvoice -- INT
  * @param $idcontact -- INT
  * @param $iduser -- INT
  * @param $recurrent -- Boolean
  */
 function sendInvoiceByEmail($idinvoice, $idcontact, $iduser, $recurrent = false)
 {
     $do_contact = new Contact();
     $do_user_rel = new UserRelations();
     $this->getId($idinvoice);
     if ($recurrent === true) {
         $this->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
     }
     $do_contact->getId($idcontact);
     $contact_name = $do_contact->firstname . ' ' . $do_contact->lastname;
     $do_contact_email = $do_contact->getChildContactEmail();
     $contact_email = $do_contact_email->getDefaultEmail();
     $do_user_detail = new User();
     $do_user_detail->getId($iduser);
     if ($contact_email) {
         $total_due = $this->amt_due;
         $total_due = $this->viewAmount($total_due);
         if ($recurrent) {
             $do_rec_invoice = new RecurrentInvoice();
             $idrec = $do_rec_invoice->checkIfInvoiceIsInRecurrent($idinvoice);
             if ($idrec) {
                 $email_template = new EmailTemplate("ofuz_send_recurrent_invoice");
                 $do_rec_invoice->getId($idrec);
                 $next_due_date = $do_rec_invoice->nextdate;
                 $recurrence = $do_rec_invoice->recurrence;
                 $recurrence_type = $do_rec_invoice->recurrence_type;
             } else {
                 $email_template = new EmailTemplate("ofuz_send_invoice");
             }
         } else {
             $email_template = new EmailTemplate("ofuz_send_invoice");
         }
         if ($this->status == 'Quote') {
             $email_template = new EmailTemplate("ofuz_send_quote");
         }
         $email_template->setSenderName($do_user_detail->getFullName());
         $email_template->setSenderEmail($do_user_detail->email);
         $signature = $do_user_detail->company . '<br />' . $do_user_detail->getFullName();
         $description = $this->description;
         $invoice_url = $GLOBALS['cfg_ofuz_site_https_base'] . 'inv/' . $do_user_rel->encrypt($idinvoice) . '/' . $do_user_rel->encrypt($idcontact);
         $email_data = array('name' => $contact_name, 'sender' => $do_user_detail->getFullName(), 'company' => $do_user_detail->company, 'description' => $description, 'invoice_url' => $invoice_url, 'num' => $this->num, 'signature' => $signature, 'amount' => $total_due, 'recurrence' => $recurrence, 'recurrence_type' => $recurrence_type, 'next_due_date' => $next_due_date);
         $emailer = new Radria_Emailer();
         $emailer->setEmailTemplate($email_template);
         $emailer->mergeArray($email_data);
         $emailer->addTo($contact_email);
         //attachment starts
         // Some bug in the PDF part it does not send the correct PDF as it says due amt is 0. Happens for the cron to send recurrent inv
         //echo '<br />Calling Method generatePDFInvoice().....<br />';
         // This is fixed
         $this->generatePDFInvoice($invoice_url);
         $fpdf_file_name = $this->getEncryptedFileName("pdf");
         $pdfFilePath = "invoice_pdf/{$fpdf_file_name}";
         $pdfFile = file_get_contents($pdfFilePath);
         $at = $emailer->createAttachment($pdfFile);
         $at->type = 'image/pdf';
         $at->disposition = Zend_Mime::DISPOSITION_INLINE;
         $at->encoding = Zend_Mime::ENCODING_BASE64;
         $at->filename = $fpdf_file_name;
         //attachment ends
         $emailer->send();
         if ($this->status == 'New') {
             $this->status = 'Sent';
             $this->update();
         }
         if ($recurrent) {
             $q = new sqlQuery($this->getDbCon());
             $q->query("update invoice set status = 'Sent' where idinvoice = " . $idinvoice . " Limit 1");
             $q->free();
         }
         $_SESSION['in_page_message'] = "client_invoice_sent";
         $_SESSION['in_page_message_data']['contact_email'] = $contact_email;
     } else {
         $_SESSION['in_page_message'] = "invoice_client_email_not_found";
     }
     $do_user_detail->free();
 }
コード例 #3
0
ファイル: invoices.php プロジェクト: jacquesbagui/ofuz
        if ($_SESSION['do_invoice_list']->discount) {
            $dis = $_SESSION['do_invoice_list']->discount;
        } else {
            $dis = "";
        }
        // $invoice_cal_data = $_SESSION['do_invoice']->getInvoiceCalculations($_SESSION['do_invoice']->idinvoice,$_SESSION['do_invoice']->amount,$dis);
        if ($_SESSION['do_invoice_list']->status == 'Paid') {
            $statuscolor = "#009900";
        } elseif ($_SESSION['do_invoice_list']->status == 'Partial') {
            $statuscolor = "#EA8484";
        } elseif ($_SESSION['do_invoice_list']->status == 'Sent') {
            $statuscolor = "#677CDF";
        } else {
            $statuscolor = "#000000";
        }
        $is_recurrent = $do_rec_inv->checkIfInvoiceIsInRecurrent($_SESSION['do_invoice_list']->idinvoice);
        if ($is_recurrent) {
            $rec_inv_icon = '<img src="images/recurrent_invoice.png" title="Recurrent Invoice" alt="Recurrent Invoice" class="invoice_list_recurrent" />';
        } else {
            $rec_inv_icon = '';
        }
        ?>
                <tr class="invoice_list_row" onclick="window.location.href='<?php 
        echo "/Invoice/" . $_SESSION['do_invoice_list']->idinvoice;
        ?>
'" title="<?php 
        echo str_replace('"', "'", $_SESSION['do_invoice_list']->description);
        ?>
">
                    <td class="center_text"><?php 
        echo $_SESSION['do_invoice_list']->num . " " . $rec_inv_icon;
コード例 #4
0
 /**
  * Delete recurence form an invoice
  */
 function stop_recurrent()
 {
     $do_api_invoice = new Invoice();
     $do_api_rec_invoice = new RecurrentInvoice();
     if (!$do_api_invoice->isInvoiceOwner($this->idinvoice, $this->iduser)) {
         $this->setMessage("711", "Invoice does not belong to you");
         return false;
     } elseif ($do_api_rec_invoice->checkIfInvoiceIsInRecurrent($this->idinvoice)) {
         if ($do_api_rec_invoice->deleteRecurrentInvoice($this->idinvoice)) {
             $this->setMessage("750", "Recurence for invoice " . $this->idinvoice . " as been removed", "ok");
             return True;
         } else {
             $this->setMessage("733", "Invoice:" . $this->idinvoice . " Doesn't has any recurrence", "fail");
             return false;
         }
     } else {
         $this->setMessage("733", "Invoice:" . $this->idinvoice . " Doesn't has any recurrence", "fail");
         return false;
     }
 }