/** * _writeInvoice : Individual & Korporasi * @return */ function _writeInvoice($memberId, $totalPromo, $discPromo, $payment, $access = '') { $aclMan = Pandamp_Acl::manager(); $tblInvoice = new Pandamp_Modules_Payment_Invoice_Model_Invoice(); $where = $tblInvoice->getAdapter()->quoteInto("uid=?", $memberId); $rowInvoice = $tblInvoice->fetchAll($where); if (count($rowInvoice) <= 0) { $rowInvoice = $tblInvoice->fetchNew(); $rowInvoice->uid = $memberId; $rowInvoice->price = $totalPromo; $rowInvoice->discount = $discPromo; $rowInvoice->invoiceOutDate = date("Y-m-d"); $rowInvoice->invoiceConfirmDate = "0000-00-00"; $temptime = time(); $temptime = Pandamp_Lib_Formater::DateAdd('d', 5, $temptime); $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime); $tblUser = new Pandamp_Modules_Identity_User_Model_User(); $rowUser = $tblUser->fetchRow("kopel=" . $memberId); // add user to gacl // $aclMan->addUser($rowUser->username,'member_gratis'); if (empty($access)) { $rowInvoice->save(); } else { $result = $rowInvoice->save(); if ($result) { $response['success'] = true; $response['message'] = "set invoice:{$memberId} successfully"; } else { $response['failure'] = true; } echo Zend_Json::encode($response); } } else { if (!empty($access)) { $response['success'] = true; $response['message'] = "invoice:{$memberId} sudah dibuat!"; echo Zend_Json::encode($response); } } }
function renewInvoiceAction() { $uid = $this->_getParam('uid') ? $this->_getParam('uid') : ''; $iid = $this->_getParam('iid') ? $this->_getParam('iid') : ''; $tblUser = new Pandamp_Modules_Identity_User_Model_User(); $rowUser = $tblUser->fetchRow("kopel=" . $uid); $tblInvoice = new Pandamp_Modules_Payment_Invoice_Model_Invoice(); $rowset = $tblInvoice->fetchRow("invoiceId=" . $iid . " AND isPaid='Y'"); if ($rowset) { try { $rowInvoice = $tblInvoice->fetchNew(); $rowInvoice->uid = $uid; $rowInvoice->price = $rowset->price; $rowInvoice->discount = $rowset->discount; $rowInvoice->invoiceOutDate = $rowset->expirationDate; $rowInvoice->invoiceConfirmDate = date("Y-m-d"); $rowInvoice->clientBankAccount = $rowset->clientBankAccount; $rowInvoice->isPaid = 'Y'; // get expiration date $temptime = time(); $temptime = Pandamp_Lib_Formater::DateAdd('m', $rowUser->paymentId, $temptime); $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime); $rowInvoice->save(); $this->view->success = true; $this->view->message = "Renewable Invoice:" . $uid . " successfully"; } catch (Exception $e) { $this->view->success = false; $this->view->message = $e->getMessage(); } } else { $this->view->success = false; $this->view->message = "Invalid invoice"; } }