/**
  * Constructor
  */
 public function __construct(Invoice $invoice, array $wallets)
 {
     $this->invoice = $invoice;
     $this->wallets = $wallets;
     $defaults = array('LMI_SIM_MODE' => sfConfig::get('app_webmoney_sim_mode'), 'LMI_PAYMENT_NO' => $invoice->getId(), 'LMI_PAYMENT_DESC_BASE64' => base64_encode($invoice->getDescription()));
     parent::__construct($defaults);
 }
 /**
  * Constructor
  */
 public function __construct(Invoice $invoice)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     $defaults = array('WMI_MERCHANT_ID' => sfConfig::get('app_w1_merchant'), 'WMI_PAYMENT_AMOUNT' => sprintf('%01.2f', $invoice->getAmount()), 'WMI_CURRENCY_ID' => 980, 'WMI_PAYMENT_NO' => $invoice->getId(), 'WMI_DESCRIPTION' => $invoice->geDescription(), 'WMI_SUCCESS_URL' => url_for('payment_w1_success', array(), true), 'WMI_FAIL_URL' => url_for('payment_w1_fail', array(), true), 'WMI_PTENABLED' => 'CashTerminalUAH');
     $defaults['WMI_SIGNATURE'] = $this->createSign($defaults);
     parent::__construct($defaults);
 }
 /**
  * Constructor
  */
 public function __construct(Invoice $invoice)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'Date'));
     $resultUrl = 'https://' . sfContext::getInstance()->getRequest()->getHost() . url_for('payment_liqpay_result');
     $defaults = array('version' => '1.1', 'merchant_id' => sfConfig::get('app_liqpay_merchant'), 'amount' => $invoice->getAmount(), 'currency' => 'UAH', 'order_id' => $invoice->getId(), 'description' => $invoice->getDescription(), 'result_url' => $resultUrl, 'server_url' => $resultUrl);
     parent::__construct($defaults);
 }
 /**
  * Delete all items for a invoice
  *
  * @param Invoice $invoice
  * @return null
  */
 function deleteByInvoice($invoice)
 {
     db_begin_work();
     $execute = db_execute('DELETE FROM ' . TABLE_PREFIX . 'invoice_time_records WHERE invoice_id = ?', $invoice->getId());
     if ($execute && !is_error($execute)) {
         $delete = InvoiceItems::delete(array('invoice_id = ?', $invoice->getId()));
         if ($delete && !is_error($delete)) {
             db_commit();
         } else {
             db_rollback();
         }
         // if
         return $delete;
     } else {
         db_rollback();
         return $execute;
     }
     // if
 }
예제 #5
0
 public function encodeInvoice(Invoice $invoice)
 {
     $data = ['id' => $invoice->getId(), 'number' => $invoice->getNumber(), 'name' => $invoice->getName(), 'created' => $invoice->getCreated(), 'delivered' => $invoice->getDelivered(), 'due' => $invoice->getDue(), 'status' => $invoice->getStatus(), 'variable_symbol' => $invoice->getVariableSymbol(), 'constant_symbol' => $invoice->getConstantSymbol(), 'description' => $invoice->getDescription(), 'items' => $this->encodeItems($invoice->getItems()), 'price' => $invoice->getPrice(), 'price_total' => $invoice->getPriceTotal(), 'currency' => $invoice->getCurrency()];
     if ($invoice->getClient()) {
         $data['client'] = $this->encodeClient($invoice->getClient());
     }
     if ($invoice->getShippingAddress()) {
         $data['shipping_address'] = $this->encodeAddress($invoice->getShippingAddress());
     }
     if ($invoice->getDiscount() && $invoice->getDiscount()->getType() != 'none') {
         $data['discount'] = ['type' => $invoice->getDiscount()->getType(), 'value' => $invoice->getDiscount()->getValue()];
     }
     return json_encode(['invoice' => $data]);
 }
예제 #6
0
 /**
  * function to get the invoice due amount
  * @param integer $idinvoice
  * @param double $grand_total
  * @return double
  */
 public function get_due_amount($idinvoice, $grand_total = 0)
 {
     $total_payment_made = 0;
     if ((int) $grand_total == 0) {
         $do_invoice = new Invoice();
         $do_invoice->getId($idinvoice);
         $grand_total = $do_invoice->grand_total;
     }
     $qry = "\n\t\tselect coalesce(sum(p.amount),0) as amount\n\t\tfrom paymentlog p\n\t\tjoin invoice_payments ip on ip.idpaymentlog = p.idpaymentlog\n\t\twhere ip.idinvoice = ? and p.transaction_type = 'charge'\n\t\t";
     $stmt = $this->getDbConnection()->executeQuery($qry, array($idinvoice));
     if ($stmt->rowCount() > 0) {
         $data = $stmt->fetch();
         $total_payment_made = $data['amount'];
     }
     return $grand_total - $total_payment_made;
 }
 /**
  * Page is displayed when issued invoice is edited
  * 
  * @param void
  * @return null
  */
 function notify()
 {
     $this->wireframe->print_button = false;
     if ($this->active_invoice->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_invoice->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $company = $this->active_invoice->getCompany();
     if (!instance_of($company, 'Company')) {
         $this->httpError(HTTP_ERR_CONFLICT);
     }
     // if
     if (!$company->hasManagers()) {
         flash_error("Sorry, there's nobody in :company_name to whom we can email the invoice", array('company_name' => $company->getName()));
         $this->redirectToUrl($this->active_invoice->getViewUrl());
     }
     // if
     $notify_url = assemble_url('invoice_notify', array('invoice_id' => $this->active_invoice->getId()));
     $users = $company->getUsers();
     $this->smarty->assign(array('users' => $users, 'company' => $company, 'notify_url' => $notify_url));
     $issue_data = $this->request->post('issue');
     if ($this->request->isSubmitted()) {
         if (isset($issue_data['send_emails']) && $issue_data['send_emails']) {
             $issue_to = Users::findById($issue_data['user_id']);
             if (instance_of($issue_to, 'User')) {
                 $filename_name = 'invoice_' . $this->active_invoice->getId() . '.pdf';
                 $filename = WORK_PATH . '/' . $filename_name;
                 require_once INVOICING_MODULE_PATH . '/models/InvoicePdf.class.php';
                 InvoicePDF::save($this->active_invoice, $filename);
                 ApplicationMailer::send($issue_to, 'invoicing/issue', array('issued_by_name' => $this->logged_user->getDisplayName(), 'issued_by_url' => $this->logged_user->getViewUrl(), 'invoice_number' => $this->active_invoice->getNumber(), 'invoice_url' => $this->active_invoice->getCompanyViewUrl(), 'pdf_url' => $this->active_invoice->getCompanyPdfUrl()), null, array(array('path' => $filename)));
                 @unlink($filename);
                 flash_success('Email sent successfully');
             } else {
                 flash_error('User does not exists');
                 $this->redirectToUrl($notify_url);
             }
             // if
         }
         // if
         $this->redirectToUrl($this->active_invoice->getViewUrl());
     }
     // if
 }
예제 #8
0
파일: edit.php 프로젝트: sQcrm/sqcrm
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Invoice edit 
* @author Abhik Chakraborty
*/
$do_crmfields = new CRMFields();
$do_block = new Block();
$do_block->get_block_by_module($module_id);
$do_global_settings = new CRMGlobalSettings();
$inv_terms_cond = $do_global_settings->get_inventory_terms_condition();
$tems_condition = $inv_terms_cond["invoice_terms_condition"];
$module_obj = new Invoice();
$module_obj->getId($sqcrm_record_id);
$do_lineitems = new Lineitems();
$do_lineitems->get_line_items($module_id, $sqcrm_record_id);
$do_products = new Products();
$lineitems = array();
if ($do_lineitems->getNumRows() > 0) {
    while ($do_lineitems->next()) {
        $product_available_tax = '';
        if ($do_lineitems->item_type == 'product') {
            $product_available_tax = $do_products->get_products_tax($do_lineitems->item_value);
        }
        $lineitems[] = array("idlineitems" => $do_lineitems->idlineitems, "item_type" => $do_lineitems->item_type, "item_name" => $do_lineitems->item_name, "item_value" => $do_lineitems->item_value, "item_description" => $do_lineitems->item_description, "item_quantity" => $do_lineitems->item_quantity, "item_price" => $do_lineitems->item_price, "discount_type" => $do_lineitems->discount_type, "discount_value" => $do_lineitems->discount_value, "discounted_amount" => $do_lineitems->discounted_amount, "tax_values" => $do_lineitems->tax_values, "product_available_tax" => $product_available_tax, "taxed_amount" => $do_lineitems->taxed_amount, "total_after_discount" => $do_lineitems->total_after_discount, "total_after_tax" => $do_lineitems->total_after_tax, "net_total" => $do_lineitems->net_total);
    }
}
//print_r($lineitems);
if (isset($_GET["return_page"]) && $_GET["return_page"] != '') {
    $return = $_GET["return_page"];
예제 #9
0
 /**
  * Method to send Send Invoice Apporove/Reject Email to the Invoice Owner
  * @param $iduser -- INT
  * @param $idinvoice -- INT
  * @param $status -- STRING
  * @param $rejected_reason -- STRING
  */
 function sendInvoiceApproveReject($iduser, $idinvoice, $status, $rejected_reason = "")
 {
     $do_inv = new Invoice();
     $do_inv_user = new User();
     $do_contact = new Contact();
     $do_inv->getId($idinvoice);
     $do_inv_user->getId($iduser);
     $do_contact->getId($do_inv->idcontact);
     $total_due = $do_inv->amt_due;
     $inv_num = $do_inv->num;
     $inv_desc = $do_inv->description;
     $inv_address = nl2br($this->Only1brFirstLineBlack($do_inv->invoice_address));
     $contact_name = $do_contact->firstname . ' ' . $do_contact->lastname;
     if ($do_contact->email_address != '') {
         $contact_email = $do_contact->email_address;
     } else {
         $ContactEmail = $do_contact->getChildContactEmail();
         if ($ContactEmail->getNumRows()) {
             $contact_email = $ContactEmail->email_address;
         }
     }
     if ($contact_email == '') {
         $contact_email = '*****@*****.**';
     }
     if ($status == "Accept") {
         $email_template = new EmailTemplate("ofuz_inv_accept_confirmation");
     }
     $do_user_rel = new UserRelations();
     $invoice_url = $GLOBALS['cfg_ofuz_site_https_base'] . 'inv/' . $do_user_rel->encrypt($idinvoice) . '/' . $do_user_rel->encrypt($do_inv->idcontact);
     //$email_template->setSubject(_("Invoice #").$inv_num.' '.$inv_desc." "._("has been accepted by")." ".$contact_name);
     $email_template->setSenderName($contact_name);
     $email_template->setSenderEmail($contact_email);
     $signature = $inv_address;
     $email_data = array('name' => $contact_name, 'contact' => $contact_name, 'description' => $inv_desc, 'signature' => $signature, 'amount' => $total_due, 'num' => $inv_num, 'invoice_url' => $invoice_url, 'address' => $inv_address);
     $emailer = new Radria_Emailer();
     $emailer->setEmailTemplate($email_template);
     $emailer->mergeArray($email_data);
     $emailer->addTo($do_inv_user->email);
     $emailer->send();
 }
예제 #10
0
 /**
  * Send reminder
  * 
  * @param Invoice $invoice
  * @param Invoice_Envelope $envelope
  * @return ApiConnector 
  */
 public function remind(Invoice $invoice, Invoice_Envelope $envelope)
 {
     $envelope->setData(array('invoiceId' => $invoice->getId()));
     $response = $this->request($this->buildUrl($invoice, null, '/send_reminder'), 'PUT', $this->mapper->mapToStorage($envelope));
     return $this->mapper->mapFromStorage($response);
 }
예제 #11
0
 function get_inv_amt_due()
 {
     $do_api_invoice = new Invoice();
     $do_api_invoice->getId($this->idinvoice);
     if ($do_api_invoice->isInvoiceOwner($this->idinvoice, $this->iduser)) {
         $due_amt = $do_api_invoice->getDueAmount($this->idinvoice);
         $this->setValues(array("due_amount" => $due_amt, "idinvoice" => $this->idinvoice));
         return true;
     } else {
         $this->setMessage("711", "Invoice does not belong to you" . $this->idinvoice . "_" . $this->iduser, 'fail');
         return false;
     }
 }
예제 #12
0
    /**
     * function to generate inventory (quote,invoice,sales order,purchase order) PDF
     * @param integer $idquotes
     * @param boolean $save
     * @see http://www.mpdf1.com/mpdf/index.php
     */
    public function generate_inventory_pdf($idrecord, $idmodule, $save = false)
    {
        include_once BASE_PATH . THIRD_PARTY_LIB_PATH . "/mpdf/mpdf.php";
        //echo BASE_PATH.THIRD_PARTY_LIB_PATH ;exit;
        $pdf = new \mPDF();
        $crm_global_settings = new \CRMGlobalSettings();
        if ($idmodule == 13) {
            $obj = new \Quotes();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('quote_num_prefix');
            $inventory_type = _('QUOTE');
            $inv = 'q';
            $inv_number_fld = 'quote_number';
            $inv_date_fld = 'valid_till';
            $file_name = 'Quote_' . $prefix . $obj->quote_number . '.pdf';
            $inventory_number = _('Quote #');
        } elseif ($idmodule == 14) {
            $obj = new \SalesOrder();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('salesorder_num_prefix');
            $inventory_type = _('SALES ORDER');
            $inv = 'so';
            $inv_number_fld = 'sales_order_number';
            $inv_date_fld = 'due_date';
            $file_name = 'SalesOrder_' . $prefix . $obj->sales_order_number . '.pdf';
            $inventory_number = _('Sales Order #');
        } elseif ($idmodule == 15) {
            $obj = new \Invoice();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('invoice_num_prefix');
            $inventory_type = _('INVOICE');
            $inv = 'inv';
            $inv_number_fld = 'invoice_number';
            $inv_date_fld = 'due_date';
            $file_name = 'Invoice_' . $prefix . $obj->invoice_number . '.pdf';
            $inventory_number = _('Invoice #');
        } elseif ($idmodule == 16) {
            $obj = new \PurchaseOrder();
            $obj->getId($idrecord);
            $prefix = $crm_global_settings->get_setting_data_by_name('purchaseorder_num_prefix');
            $inventory_type = _('PURCHASE ORDER');
            $inv = 'po';
            $inv_number_fld = 'po_number';
            $inv_date_fld = 'due_date';
            $file_name = 'PurchaseOrder_' . $prefix . $obj->po_number . '.pdf';
            $inventory_number = _('Purchase Order #');
        }
        $inventory_logo = $crm_global_settings->get_setting_data_by_name('inventory_logo');
        $company_address = $crm_global_settings->get_setting_data_by_name('company_address');
        $do_lineitems = new \Lineitems();
        $do_lineitems->get_line_items($idmodule, $idrecord);
        $lineitems = array();
        if ($do_lineitems->getNumRows() > 0) {
            while ($do_lineitems->next()) {
                $lineitems[] = array("idlineitems" => $do_lineitems->idlineitems, "item_type" => $do_lineitems->item_type, "item_name" => $do_lineitems->item_name, "item_value" => $do_lineitems->item_value, "item_description" => $do_lineitems->item_description, "item_quantity" => $do_lineitems->item_quantity, "item_price" => $do_lineitems->item_price, "discount_type" => $do_lineitems->discount_type, "discount_value" => $do_lineitems->discount_value, "discounted_amount" => $do_lineitems->discounted_amount, "tax_values" => $do_lineitems->tax_values, "taxed_amount" => $do_lineitems->taxed_amount, "total_after_discount" => $do_lineitems->total_after_discount, "total_after_tax" => $do_lineitems->total_after_tax, "net_total" => $do_lineitems->net_total);
            }
        }
        $html = '';
        if (is_array($lineitems) && count($lineitems) > 0) {
            //--load the stylesheet
            $stylesheet = file_get_contents(BASE_PATH . '/themes/custom-css/inventory_export.css');
            $pdf->WriteHTML($stylesheet, 1);
            $html .= '
			<div>
				<div class="inv_wrapper">
					<h1 class="inv_heading">' . $inventory_type . '</h1>
					<div class="inv_address_wrapper">
						<p class="inv_address_section">
							<span class="inv_address_to_from">FROM:</span><br>
							' . nl2br($company_address) . '
						</p>
					</div>
					<div class="inv_company_address_wrapper">
						<img class="inv_company_address_logo" src="' . $GLOBALS['FILE_UPLOAD_DISPLAY_PATH'] . '/' . $inventory_logo . '">
					</div>
				</div>
				<div style="clear:both;"></div>
				<div class="inv_wrapper">
				<div class="inv_address_wrapper">
					<p class="inv_address_section">
						<span class="inv_address_to_from">To:</span><br>' . $this->generate_to_address($obj, $inv) . '
					</p>
				</div>
				<div class="inv_brief_section">
					<table class="inv_brief_section_table">
						<tr>
							<th class="inv_brief_section_table_heading">
								<span>' . $inventory_number . '</span>
							</th>
							<td class="inv_brief_section_table_content">
								<span>' . $prefix . $obj->{$inv_number_fld} . '</span>
							</td>
						</tr>
						<tr>
							<th class="inv_brief_section_table_heading">
								<span>Date</span>
							</th>
							<td class="inv_brief_section_table_content">
								<span>' . \FieldType9::display_value($obj->{$inv_date_fld}) . '</span>
							</td>
						</tr>
						<tr>
							<th class="inv_brief_section_table_heading">
								<span>Amount Due</span>
							</th>
							<td class="inv_brief_section_table_content">
								<span>' . \FieldType30::display_value($obj->grand_total) . '</span>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<div style="clear:both;"></div>
			<br>
			';
            $html .= '
			<table class="inv_line_table">
				<thead>
					<tr>
						<th class="inv_line_table_header inv_line_table_header_width_30">
							<span>Item Name</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_10">
							<span>Qty</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_30">
							<span>Price</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_15">
							<span>Total</span>
						</th>
						<th class="inv_line_table_header inv_line_table_header_width_15">
							<span>Net Price</span>
						</th>
					</tr>
				</thead>
			';
            $html .= '<tbody>';
            foreach ($lineitems as $key => $items) {
                $line_discount = '';
                if ($items["discount_type"] == 'direct') {
                    $line_discount = _('Discount') . '-' . \FieldType30::display_value($items["discount_value"]);
                } elseif ($items["discount_type"] == 'percentage') {
                    $line_discount = _('Discount') . '-' . $items["discount_value"] . ' %';
                } else {
                    $line_discount = _('Discount') . '-' . _('no discount');
                }
                $line_tax = '';
                if ($items["tax_values"] != '') {
                    $line_tax = ' - ' . rtrim($items["tax_values"], ',');
                } else {
                    $line_tax = ' - no tax';
                }
                $html .= '
				<tr>
					<td class="inv_line_table_content inv_line_table_content_vertical_top">
						<div class="inv_line_table_content_block">
							' . $items["item_name"] . ' <br><br>
							' . nl2br($items["item_description"]) . '
						</div>
					</td>
					<td class="inv_line_table_content inv_line_table_content_vertical_top">
						<div class="inv_line_table_content_block">
							' . \FieldType16::display_value($items["item_quantity"]) . '
						</div>
					</td>
					<td class="inv_line_table_content">
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["item_price"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . $line_discount . '
						</div>
						<div class="inv_line_table_content_block">
							<b>Total after discount</b>
						</div>
						<div class="inv_line_table_content_block">
							<b>Tax </b> ' . $line_tax . '
						</div>
					</td>
					<td class="inv_line_table_content">
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["item_price"] * $items["item_quantity"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["discounted_amount"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["total_after_discount"]) . '
						</div>
						<div class="inv_line_table_content_block">
							' . \FieldType30::display_value($items["taxed_amount"]) . '
						</div>
					</td>
					<td class="inv_line_table_content inv_line_table_content_vertical_top">
						' . \FieldType30::display_value($items["net_total"]) . '
					</td>
				</tr>';
            }
            $html .= '
			</tbody></table>';
            $net_discount = '';
            if ($obj->discount_type == 'percentage') {
                $net_discount = $obj->discount_value . ' %';
            } elseif ($obj->discount_type == 'direct') {
                $net_discount = FieldType30::display_value($obj->discount_value);
            } else {
                $net_discount = _('no discount');
            }
            $net_tax = '';
            if ($obj->tax_values != '') {
                $net_tax = rtrim($obj->tax_values, ',');
            }
            $ship_hand_tax = '';
            if ($obj->shipping_handling_tax_values != '') {
                $ship_hand_tax = rtrim($obj->shipping_handling_tax_values, ',');
            }
            $final_adj = '';
            if ($obj->final_adjustment_type == 'add') {
                $final_adj = '(+)';
            } elseif ($obj->final_adjustment_type == 'deduct') {
                $final_adj = '(-)';
            }
            $html .= '
			<div style="clear:both;"></div>
			<br>
			<div class="inv_grand_total_section">
				<table class="inv_grand_total_table">
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Net Total</b></span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->net_total) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Discount -</b> ' . $net_discount . '</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->discounted_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Tax -</b> ' . $net_tax . ' </span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->taxed_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Shipping/Handling charges</b></span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->shipping_handling_charge) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Shipping/Handling Tax -</b>' . $ship_hand_tax . '</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->shipping_handling_taxed_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Final Adjustment</b>' . $final_adj . '</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->final_adjustment_amount) . '</span>
						</td>
					</tr>
					<tr>
						<td class="inv_grand_total_table_header">
							<span><b>Grand Total</span>
						</td>
						<td class="inv_grand_total_table_content">
							<span>' . \FieldType30::display_value($obj->grand_total) . '</span>
						</td>
					</tr>
				</table>
			</div>
			<div style="clear:both;"></div>
			<br>
			<h3 class="inv_terms_cond_section">
				<span>Terms & Condition</span>
			</h3>
			<div style="top:2px;">
				<p>
					' . nl2br($obj->terms_condition) . '
				</p>
			</div></div>';
        }
        if (true === $save) {
            $pdf->WriteHTML($html);
            $pdf->Output(OUTBOUND_PATH . '/' . $file_name, 'F');
            return $file_name;
        } else {
            $pdf->WriteHTML($html, 2);
            $pdf->Output($file_name, 'D');
            exit;
        }
    }
예제 #13
0
<?php

/* * * * *
* This is script to update the user after the payment made for trail user. 
* This is curl post for this script
* @param Idinvoice. 
* * * * * */
ob_start();
include_once "config.php";
//amt_paid=$amt_paid&c=$check_sum&pay_type=$pay_type&pay_status=$payment_status
$invoice_id = $_POST['id'];
$payment_status = $_POST['pay_status'];
$invoice_id = '6';
$invoice = new Invoice();
$invoice->getId($invoice_id);
$iduser = $invoice->iduser;
$date = date('Y-m-d');
$do_user = new User();
$do_user->getId($iduser);
$do_user->plan = 'Paid';
$do_user->regdate = $date;
$do_user->update();
if (!is_object($_SESSION['do_User'])) {
    if ($_SESSION['upgrade'] === true) {
        unset($_SESSION['upgrade']);
    }
}
 /**
  * Drop payments by invoice
  *
  * @param Invoice $invoice
  * @return boolean
  */
 function deleteByInvoice($invoice)
 {
     return InvoicePayments::delete(array('invoice_id = ?', $invoice->getId()));
 }
예제 #15
0
 } elseif ($_SESSION['in_page_message_inv_mul_pay_del'] == 'Yes') {
     if (isset($_SESSION["in_page_message_inv_idpaymentlog"]) && $_SESSION["in_page_message_inv_idpaymentlog"] != '') {
         $do_paymentlog = new Paymentlog();
         $do_paymentlog->getMulInvoicesForPayment((int) $_SESSION["in_page_message_inv_idpaymentlog"]);
         $do_invoice_del = new Invoice();
         $do_contact = new Contact();
         echo '<div style="width:700px;margin-left:0px;margin-top:5px;height:30px;text-align:left;position: relative; color:#FFA500;font-size:14px;">';
         echo '<div style="width:100px;float:left;"><b>' . _('Number') . '</b></div>';
         echo '<div style="width:250px;float:left;"><b>' . _('Contact') . '</b></div>';
         echo '<div style="width:100px;float:left;"><b>' . _('Due Date') . '</b></div>';
         echo '<div style="width:100px;float:left;"><b>' . _('Total') . '</b></div>';
         echo '<div style="width:100px;float:left;"><b>' . _('Due') . '</b></div>';
         echo '</div>';
         echo '<div style="width:700px;margin-left:0px;margin-top:5px;height:30px;text-align:left;position: relative;font-size:12px;">';
         while ($do_paymentlog->next()) {
             $do_invoice_del->getId($do_paymentlog->idinvoice);
             echo '<div style="width:100px;float:left;">' . $do_invoice_del->num . ' </div> ';
             $contact = $do_contact->getContact_Company_ForInvoice($do_invoice_del->idcontact, $do_invoice_del->idcompany);
             if ($contact == '') {
                 $contact = '--';
             }
             echo ' <div style="width:250px;float:left;">' . $contact . '</div>';
             echo '<div style="width:100px;float:left;">' . $do_invoice_del->getInvFormattedDate($do_invoice_del->due_date) . '</div>';
             echo '<div style="width:100px;float:left;">' . $do_invoice_del->viewAmount($do_invoice_del->net_total) . '</div>';
             echo '<div style="width:100px;float:left;">' . $do_invoice_del->viewAmount($do_invoice_del->amt_due) . '</div>';
         }
         echo '</div>';
         echo '<br /><br />';
         $e_del_payment = new Event("PaymentLog->eventDeletePaymentLog");
         $e_del_payment->addParam("id", (int) $_SESSION["in_page_message_inv_idpaymentlog"]);
         $e_del_payment->addParam("del_mul_confirm", "Yes");
예제 #16
0
 function deleteInvoiceRelated($iduser = "")
 {
     if ($iduser == "") {
         $iduser = $_SESSION['do_User']->iduser;
     }
     $q = new sqlQuery($this->getDbCon());
     $q->query("select idinvoice from invoice where iduser = "******"idinvoice"));
             //Del Invoice Lines
             $inv_lines = $do_del_inv->getChildInvoiceLine();
             while ($inv_lines->next()) {
                 $inv_lines->delete();
             }
             //Del Recurrence Invoice
             $rec_inv = $do_del_inv->getChildRecurrentInvoice();
             $del_rec_inv_cc = new sqlQuery($this->getDbCon());
             while ($rec_inv->next()) {
                 // Del Recurrent Invoice CC
                 $del_rec_inv_cc->query("delete from recurrent_invoice_cc \n                                           where idrecurrentinvoice = " . $rec_inv->idrecurrentinvoice);
                 $rec_inv->delete();
             }
             //Delete Payment Log
             $pay_log = $do_del_inv->getChildPaymentLog();
             while ($pay_log->next()) {
                 $pay_log->delete();
             }
             // Delete Invoice
             $do_del_inv->delete();
         }
     }
 }
 public function executeGenerateInvoice(sfWebRequest $request)
 {
     $purchase = Doctrine_Query::create()->from('Purchase p')->where('p.id = ' . $request->getParameter('id'))->fetchOne();
     //create purchase
     $invoice = new Invoice();
     $invoice->setInvno(date('h:i:s a'));
     $invoice->setCustomerId(2);
     //cash
     $invoice->setIsTemporary(2);
     //new
     $invoice->setDate(date("Y-m-d"));
     $invoice->save();
     //create purchase details
     foreach ($purchase->getPurchasedetail() as $purchdetail) {
         $invdetail = new InvoiceDetail();
         $invdetail->setInvoiceId($invoice->getId());
         $invdetail->setProductId($purchdetail->getProductId());
         $invdetail->setDescription($purchdetail->getProduct()->getName());
         $invdetail->setQty($purchdetail->getQty());
         $invdetail->setPrice(0);
         $invdetail->setTotal(0);
         $invdetail->setUnittotal(0);
         $invdetail->save();
         $invdetail->updateStockentry();
     }
     $this->redirect("invoice/view?id=" . $invoice->getId());
 }
예제 #18
0
 /**
  * Apply a Charge to an Invoice.
  *
  * @param \Litwicki\Bundle\ChargifyBundle\Handler\Invoice $entity
  * @param $data
  *
  * @throws \Exception
  */
 public function charge(Invoice $entity, $data)
 {
     try {
         $uri = sprintf('/invoices/%s/credits', $entity->getId());
         $response = $this->request($uri, 'POST', $this->postData($data));
         return $this->serializer()->deserialize($response, '\\Litwicki\\Bundle\\ChargifyBundle\\Model\\Charge', $this->format());
     } catch (\Exception $e) {
         throw $e;
     }
 }
 $do_invoice->discount = $do_recurrent->discount;
 $do_invoice->invoice_term = $do_recurrent->invoice_term;
 $do_invoice->invoice_address = $do_recurrent->invoice_address;
 $do_invoice->idcompany = $do_recurrent->idcompany;
 $do_invoice->idcontact = $do_recurrent->idcontact;
 $do_invoice->datecreated = $do_recurrent->nextdate;
 $do_invoice->invoice_note = $do_recurrent->invoice_note;
 $do_invoice->due_date = date("Y-m-d");
 $do_invoice->sub_total = $do_recurrent->sub_total;
 $do_invoice->net_total = $do_recurrent->net_total;
 $do_invoice->add();
 // Add the Invoice Line
 $idinvoice = $do_invoice->getPrimaryKeyValue();
 echo '<br />New Invoice Created :: ' . $idinvoice . '<br />';
 $do_inv_add = new Invoice();
 $do_inv_add->getId($do_recurrent->idinvoice);
 $inv_line = $do_inv_add->getChildinvoiceline();
 while ($inv_line->next()) {
     $do_inv_line->addNew();
     $do_inv_line->idinvoice = $idinvoice;
     $do_inv_line->description = $inv_line->description;
     $do_inv_line->price = $inv_line->price;
     $do_inv_line->qty = $inv_line->qty;
     $do_inv_line->total = $inv_line->total;
     $do_inv_line->item = $inv_line->item;
     $do_inv_line->add();
 }
 $do_invoice->setInvoiceCalculations($idinvoice);
 // Call this method for other calculations
 //update callback
 $do_inv_callbak = new InvoiceCallback();
예제 #20
0
 $date_paid = $today;
 $status = 'Paid';
 $invoice_note = 'Thanks for the business';
 $sub_total = $re_membership_amount;
 $net_total = $re_membership_amount;
 $amt_due = '0.00';
 $sql_update_invoice = "UPDATE invoice set\n                                      amount = '{$sub_total}',\n                                      sub_total = '{$sub_total}',\n                                      net_total = '{$net_total}', \n                                      status = '{$status}',\n                                      amt_due = '{$amt_due}',\n                                      datepaid  = '{$date_paid}'\n                            where idinvoice = " . $idinvoice;
 $do_invoice->query($sql_update_invoice);
 $do_user_data = new User();
 $do_user_data->getId($iduser);
 $customer_name = $do_user_data->firstname . ' ' . $do_user_data->lastname;
 $customer_email = $do_user_data->email;
 $signature = $do_user_data->company . '<br />' . $do_user_data->firstname . ' ' . $do_user_data->lastname;
 $docustomer_invoice = new Invoice();
 $paid_memebership_amount = $docustomer_invoice->viewAmount($re_membership_amount);
 $docustomer_invoice->getId($idinvoice);
 $email_data = array('name' => $customer_name, 'company' => $do_user_data->company, 'description' => $docustomer_invoice->desc, 'signature' => $signature, 'amount' => $paid_memebership_amount, 'num' => $docustomer_invoice->num, 'refnum' => $result['response']['id'], 'paytype' => 'Stripe', 'username' => $do_user_data->firstname, 'invoice_num' => $docustomer_invoice->num);
 //Notify User by email about his payment
 if (!empty($customer_email)) {
     $emailer = new Radria_Emailer();
     $email_template = new EmailTemplate("ofuz_inv_payment_confirmation");
     $email_template->setSenderName($customer_name);
     $email_template->setSenderEmail($customer_email);
     $email_template->free();
     $emailer->setEmailTemplate($email_template);
     $emailer->mergeArray($email_data);
     $emailer->addTo($customer_email);
     print_r($emailer);
     //$emailer->send();
 }
 //Email for admin
 $invoice_note = 'Thanks for the business';
 $sub_total = $total;
 $net_total = $total;
 $amt_due = '0.00';
 $sql_update_invoice = "UPDATE invoice set\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  amount = '{$sub_total}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  sub_total = '{$sub_total}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  net_total = '{$net_total}', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  status = '{$status}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  amt_due = '{$amt_due}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  datepaid  = '{$date_paid}'\n\t\t\t\t\t\t\t\t\t\t\t\twhere idinvoice = " . $_SESSION['do_invoice']->idinvoice;
 echo $sql_update_invoice;
 $inv_qry->query($sql_update_invoice);
 $inv_qry->free();
 $do_user_data = new User();
 $do_user_data->getId($_SESSION['do_invoice']->iduser);
 $customer_name = $do_user_data->firstname . ' ' . $do_user_data->lastname;
 $customer_email = $do_user_data->email;
 $signature = $do_user_data->company . '<br />' . $do_user_data->firstname . ' ' . $do_user_data->lastname;
 $docustomer_invoice = new Invoice();
 $paid_memebership_amount = $docustomer_invoice->viewAmount($total);
 $docustomer_invoice->getId($_SESSION['do_invoice']->idinvoice);
 $email_data = array('name' => $customer_name, 'company' => $do_user_data->company, 'description' => $docustomer_invoice->desc, 'signature' => $signature, 'amount' => $paid_memebership_amount, 'num' => $docustomer_invoice->num, 'refnum' => $result['response']['id'], 'paytype' => 'Stripe', 'username' => $do_user_data->firstname, 'invoice_num' => $docustomer_invoice->num);
 //Notify User by email about his payment
 if (!empty($customer_email)) {
     $emailer = new Radria_Emailer();
     $email_template = new EmailTemplate("ofuz_inv_payment_confirmation");
     $email_template->setSenderName($customer_name);
     $email_template->setSenderEmail($customer_email);
     $email_template->free();
     $emailer->setEmailTemplate($email_template);
     $emailer->mergeArray($email_data);
     $emailer->addTo($customer_email);
     print_r($emailer);
     //$emailer->send();
 }
 //Email for admin