Beispiel #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);
     }
 }
Beispiel #2
0
 /**
  * createinvoiceAction
  * Create an invoice reference
  * @return void
  */
 public function createinvoiceAction()
 {
     $request = $this->getRequest();
     if (is_numeric($request->id) && !Orders::isInvoiced($request->id)) {
         //TODO: create invoice should only create the invoice and not set order as complete
         //Orders::Complete($request->id);
         Invoices::Create($request->id);
         $this->_helper->redirector('edit', 'orders', 'admin', array('id' => $request->id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
     }
 }
Beispiel #3
0
 /**
  * createinvoiceAction
  * Create an invoice reference
  * @return void
  */
 public function createinvoiceAction()
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if (is_numeric($request->id)) {
         $invoiceID = Invoices::Create($request->id);
         if (is_numeric($invoiceID)) {
             Invoices::setInvoice($request->id, $invoiceID);
             $this->_helper->redirector('edit', 'invoices', 'admin', array('id' => $request->id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
         } else {
             $this->_helper->redirector('edit', 'invoices', 'admin', array('id' => $request->id, 'mex' => $this->translator->translate('An invoice already exists for this order.'), 'status' => 'danger'));
         }
     }
 }