Esempio n. 1
0
 /**
  * runActivate
  * run activation procedure if payment is confirmed and order is fully paid
  */
 public static function runActivate($orderid)
 {
     Shineisp_Commons_Utilities::logs(__METHOD__ . ": payment confirmed.");
     // Let's check if we have the whole invoice paid.
     $isPaid = Orders::isPaid($orderid);
     // Check to see if order is totally paid.
     // This will generate invoice or, if an invoice is still present, it will overwrite it (proforma to invoice conversion)
     if ($isPaid) {
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": isPaid ok, payment has been completed 100%");
         // Set order status as "Paid"
         Orders::set_status($orderid, Statuses::id('paid', 'orders'));
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": subscribed services activation starts ");
         // If we have to autosetup as soon as first payment is received, let's do here.
         Orders::activateItems($orderid, 4);
         // If automatic invoice creation is set to 1, we have to create the invoice
         $autoCreateInvoice = intval(Settings::findbyParam('auto_create_invoice_after_payment'));
         $invoiceId = intval(Orders::isInvoiced($orderid));
         if (!$invoiceId) {
             // order not invoiced?
             Shineisp_Commons_Utilities::logs(__METHOD__ . ": order not invoiced.");
             if ($autoCreateInvoice === 1) {
                 Shineisp_Commons_Utilities::logs(__METHOD__ . ": start order invoicing process.");
                 // invoice not created yet. Let's create now
                 Invoices::Create($orderid);
             }
         } else {
             Shineisp_Commons_Utilities::logs(__METHOD__ . ": invoice already created overwrite of the old invoice");
             // set invoice as paid
             Invoices::overwrite($invoiceId);
         }
     } else {
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": isPaid KO, payment not completed");
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": check if one or more services have been activated when a first payment is received");
         // If we have to autosetup as soon as first payment is received, let's do here.
         Orders::activateItems($orderid, 3);
     }
 }
Esempio n. 2
0
 /**
  * overwriteAction
  * Overwrite a pdf invoice document
  * @return void
  */
 public function overwriteAction()
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     try {
         if (is_numeric($request->id)) {
             Invoices::overwrite($request->id);
             $this->_helper->redirector('edit', 'invoices', 'admin', array('id' => $request->id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
     die;
 }