/** * Save all the data in the database * @param array $data * @param integer $id */ public static function saveAll(array $data, $id = null) { if (!empty($data) && is_array($data)) { if (is_numeric($id)) { $profile = Doctrine::getTable('DomainsProfiles')->find($id); if ($profile->profile_id != $id) { return false; } } else { $profile = new DomainsProfiles(); $profile['created_at'] = date('Y-m-d h:i:s'); } $profile['customer_id'] = $data['customer_id']; $profile['company'] = $data['company']; $profile['firstname'] = $data['firstname']; $profile['lastname'] = $data['lastname']; $profile['gender'] = $data['gender']; $profile['email'] = $data['email']; $profile['phone'] = $data['phone']; $profile['fax'] = $data['fax']; $profile['birthplace'] = $data['birthplace']; $profile['birthdate'] = Shineisp_Commons_Utilities::formatDateIn($data['birthdate']); $profile['birthdistrict'] = $data['birthdistrict']; $profile['birthcountry'] = $data['birthcountry']; $profile['birthnationality'] = $data['birthnationality']; $profile['address'] = $data['address']; $profile['zip'] = $data['zip']; $profile['city'] = $data['city']; $profile['area'] = $data['area']; $profile['country_id'] = !empty($data['country_id']) ? $data['country_id'] : null; $profile['vat'] = $data['vat']; $profile['taxpayernumber'] = $data['taxpayernumber']; $profile['status_id'] = $data['status_id']; $profile['legalform_id'] = $data['legalform_id']; $profile['type_id'] = $data['type_id']; $profile['legalform_id'] = $data['legalform_id']; $profile['type_id'] = !empty($data['type_id']) ? $data['type_id'] : Null; $profile['updated_at'] = date('Y-m-d h:i:s'); if ($profile->trySave()) { // get the customer ID $data['profile_id'] = empty($data['profile_id']) ? $profile['profile_id'] : $data['profile_id']; return $profile['profile_id']; } } return false; }
/** * Save all the data * @param array $params */ public static function saveAll(array $params) { if (!empty($params['server_id']) && is_numeric($params['server_id'])) { $server = Doctrine::getTable('Servers')->find($params['server_id']); } else { $server = new Servers(); } $server->name = $params['name']; $server->ip = $params['ip']; $server->netmask = $params['netmask']; $server->host = $params['host']; $server->domain = $params['domain']; $server->description = $params['description']; $server->status_id = intval($params['status_id']); $server->isp_id = intval($params['isp_id']); $server->type_id = intval($params['type_id']); $server->panel_id = intval($params['panel_id']) ? intval($params['panel_id']) : null; $server->cost = isset($params['cost']) && is_numeric($params['cost']) ? $params['cost'] : 0; $server->max_services = isset($params['max_services']) ? intval($params['max_services']) : 0; $server->datacenter = isset($params['datacenter']) ? $params['datacenter'] : ''; $server->is_default = isset($params['is_default']) ? intval($params['is_default']) : 0; $server->buy_date = Shineisp_Commons_Utilities::formatDateIn($params['buy_date']); $server->save(); // TODO: clear other default servers for the same group. Only one server can be default in the group return $server['server_id']; }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/profile/process"); $request = $this->getRequest(); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index', 'index', 'default'); } if ($form->isValid($request->getPost())) { // Get the id $id = $this->getRequest()->getParam('customer_id'); try { // Set the new values if (is_numeric($id)) { $customer = Doctrine::getTable('Customers')->find($id); $oldCustomer = $customer->toArray(); // Get the values posted $params = $form->getValues(); $customer->company = $params['company']; $customer->firstname = $params['firstname']; $customer->lastname = $params['lastname']; $customer->email = $params['email']; $customer->birthdate = Shineisp_Commons_Utilities::formatDateIn($params['birthdate']); if (!empty($params['password'])) { $customer->password = MD5($params['password']); } $customer->birthplace = $params['birthplace']; $customer->birthdistrict = $params['birthdistrict']; $customer->birthcountry = $params['birthcountry']; $customer->birthnationality = $params['birthnationality']; $customer->vat = $params['vat']; $customer->taxpayernumber = $params['taxpayernumber']; $customer->type_id = !empty($params['company_type_id']) ? $params['company_type_id'] : NULL; $customer->legalform_id = $params['legalform']; $customer->gender = $params['gender']; // Save the data $customer->save(); $id = is_numeric($id) ? $id : $customer->getIncremented(); // Manage the address of the customer $address = new Addresses(); $mainAddress = $address->findOneByUserId($id); if ($mainAddress) { $address = $mainAddress; } $address->address = $params['address']; $address->city = $params['city']; $address->code = $params['code']; $address->country_id = $params['country_id']; $address->area = $params['area']; $address->customer_id = $id; $address->save(); if (!empty($params['contact'])) { $contacts = new Contacts(); $contacts->contact = $params['contact']; $contacts->type_id = $params['contacttypes']; $contacts->customer_id = $id; $contacts->save(); } // Add or Remove the customer email in the newsletter list Customers::newsletter_subscription($id, $params['newsletter']); $retval = Shineisp_Commons_Utilities::getEmailTemplate('profile_changed'); if ($retval) { $subject = $retval['subject']; $subject = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $retval['subject']); // Alert the administrator about the changing of the customer information $body = $retval['template']; $body = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $body); $body = str_replace("[old]", print_r($oldCustomer, true), $body); $body = str_replace("[new]", print_r($customer->toArray(), true), $body); $isp = Shineisp_Registry::get('ISP'); Shineisp_Commons_Utilities::SendEmail($isp->email, $isp->email, null, $subject, $body); } } } catch (Exception $e) { echo $e->getMessage(); die; } return $this->_helper->redirector('account', 'profile', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Profile details"); $this->view->description = $this->translator->translate("Update here your details filling the applicant form with all the information about you."); return $this->_helper->viewRenderer('applicantform'); } }
/** * Save all the data in the database * @param array $data * @param integer $id */ public static function saveAll(array $data, $id) { if (!empty($data) && is_array($data)) { if (is_numeric($id)) { $customer = Doctrine::getTable('Customers')->find($id); if ($customer->customer_id != $id) { return false; } if ($customer->isp_id != Isp::getCurrentId()) { return false; } $customer['created_at'] = date('Y-m-d h:i:s'); } else { $customer = new Customers(); } $customer['company'] = $data['company']; $customer['firstname'] = $data['firstname']; $customer['lastname'] = $data['lastname']; $customer['gender'] = $data['gender']; if (!empty($data['password'])) { $customer['password'] = crypt($data['password']); } $customer['email'] = $data['email']; $customer['birthplace'] = $data['birthplace']; $customer['birthdate'] = Shineisp_Commons_Utilities::formatDateIn($data['birthdate']); $customer['birthdistrict'] = $data['birthdistrict']; $customer['birthcountry'] = $data['birthcountry']; $customer['birthnationality'] = $data['birthnationality']; $customer['note'] = $data['note']; $customer['vat'] = $data['vat']; $customer['taxpayernumber'] = $data['taxpayernumber']; $customer['status_id'] = $data['status_id']; $customer['issubscriber'] = $data['issubscriber']; $customer['legalform_id'] = $data['legalform_id']; $customer['type_id'] = $data['type_id']; $customer['group_id'] = $data['group_id']; $customer['issubscriber'] = !empty($data['issubscriber']) ? 1 : 0; $customer['taxfree'] = !empty($data['taxfree']) ? 1 : 0; $customer['legalform_id'] = $data['legalform_id']; $customer['type_id'] = !empty($data['type_id']) ? $data['type_id'] : Null; $customer['parent_id'] = !empty($data['parent_id']) ? $data['parent_id'] : Null; $customer['isreseller'] = !empty($data['isreseller']) ? $data['isreseller'] : Null; $customer['ignore_latefee'] = (bool) $data['ignore_latefee']; $customer['language_id'] = $data['language_id']; $customer['updated_at'] = date('Y-m-d h:i:s'); $customer['isp_id'] = Isp::getCurrentId(); $customer->save(); // get the customer ID $data['customer_id'] = empty($data['customer_id']) ? $customer['customer_id'] : $data['customer_id']; // Handle the customer address if (!empty($data['address'])) { Addresses::AddNew($data); } // Handle the customer contact if (!empty($data['contact'])) { Contacts::AddNew(array('contact' => $data['contact'], 'type_id' => $data['contacttypes'], 'customer_id' => $customer['customer_id'])); } // Newsletter OptIn if (!empty($data['issubscriber']) && $data['issubscriber'] == 1) { NewslettersSubscribers::customer_optIn($customer['customer_id']); // Add the customer email in the newsletter list } else { NewslettersSubscribers::customer_optOut($customer['customer_id']); // Remove the customer email from the newsletter subscriber list } // Save the upload file self::UploadDocument($customer['customer_id'], $data['filecategory']); return $customer['customer_id']; } return false; }
public function loadRecords(array $params) { $config = $this->getConfig(); $records = array(); $rows = array(); $iTotalRecords = 0; $iFilteredTotal = 0; $sOrder = ""; // Get the common information in order to read the records and the columns of the list $columns = !empty($config['datagrid']['columns']) ? $config['datagrid']['columns'] : null; $dq = !empty($config['datagrid']['dqrecordset']) && is_object($config['datagrid']['dqrecordset']) ? $config['datagrid']['dqrecordset'] : null; $recordset = !empty($config['datagrid']['recordset']) ? $config['datagrid']['recordset'] : null; // Check if the doctrine object is active if (!empty($dq) && is_object($dq)) { $iTotalRecords = $dq->count(); $iFilteredTotal = $dq->count(); $mainsearchvalue = !empty($params['sSearch']) ? $params['sSearch'] : null; if (!empty($params['iColumns'])) { // Filter the records per each column field for ($i = 0; $i < intval($params['iColumns']); $i++) { if ($params['bSearchable_' . $i] == "true") { $colsearchvalue = !empty($params['sSearch_' . $i]) ? $params['sSearch_' . $i] : null; if (!empty($columns[$i]['field'])) { if ($mainsearchvalue) { if (Shineisp_Commons_Utilities::is_valid_date($mainsearchvalue)) { $mainsearchvalue = Shineisp_Commons_Utilities::formatDateIn($mainsearchvalue); $dq->orWhere($columns[$i]['field'] . " = ?", $mainsearchvalue); } else { $dq->orWhere($columns[$i]['field'] . " like ?", "%{$mainsearchvalue}%"); } } else { if ($colsearchvalue) { if (Shineisp_Commons_Utilities::is_valid_date($colsearchvalue)) { $colsearchvalue = Shineisp_Commons_Utilities::formatDateIn($colsearchvalue); $dq->andWhere($columns[$i]['field'] . " = ?", $colsearchvalue); } else { $dq->andWhere($columns[$i]['field'] . " like ?", "%{$colsearchvalue}%"); } } } } } } } $query = $dq->getSqlQuery(); // Count the filtered records $temprs = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY); $iFilteredTotal = count($temprs); // Paging of the records if (isset($params['iDisplayStart']) && $params['iDisplayLength'] != '-1') { $dq->offset($params['iDisplayStart']); $dq->limit($params['iDisplayLength']); } // Sorting of the records if (isset($params['iSortCol_0'])) { for ($i = 0; $i < intval($params['iSortingCols']); $i++) { $j = 0; if ($params['bSortable_' . intval($params['iSortCol_' . $i])] == "true") { foreach ($columns as $column) { if (!empty($column['sortable']) && $column['sortable']) { if ($j == $params['iSortCol_0'] - 1) { $sOrder .= $column['field'] . " " . $params['sSortDir_' . $i] . ", "; } $j++; } } } } $sOrder = substr_replace($sOrder, "", -2); if (!empty($sOrder)) { $dq->orderBy($sOrder); } } #print_r($columns); #Zend_Debug::dump($sOrder); #print_r($dq->getDql()); #Zend_Debug::dump($rs); #die; // Execute the doctrine object to get the record array $rs = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY); // Complete the recordset with external values $rs = self::injectData($rs); } elseif (!empty($recordset) && is_array($recordset)) { $iFilteredTotal = count($recordset); $rs = $recordset; } $i = 0; // For each record do ... foreach ($rs as $record) { $row = array(); $row['Row'] = "row_{$i}"; foreach ($columns as $column) { if (!empty($column['alias'])) { if (!empty($column['type'])) { if ($column['type'] == "boolean") { $badge = $record[$column['alias']] == 1 ? "badge-success" : "badge-important"; $label = $record[$column['alias']] == 1 ? $this->translator->translate("Yes") : $this->translator->translate("No"); $row[] = "<span class=\"badge {$badge}\">" . $label . "</span>"; } elseif ($column['type'] == "index") { $badge = "badge-" . strtolower($record[$column['alias']]); $label = $this->translator->translate($record[$column['alias']]); $row[] = "<span class=\"badge {$badge}\">{$label}</span>"; } elseif ($column['type'] == "link" && !empty($column['link'])) { if (is_array($column['link'])) { $link = str_replace("%s", $record[$column['link']['idx']], $column['link']['href']); } else { $link = str_replace("%s", "", $column['link']); } $label = $this->translator->translate($record[$column['alias']]); $row[] = "<a href=\"{$link}\" class=\"\">{$label}</span>"; } else { $row[] = $record[$column['alias']]; } } else { $row[] = $record[$column['alias']]; } } } $records[] = $row; $i++; } $output = array("sEcho" => !empty($params['sEcho']) ? intval($params['sEcho']) : 0, "iTotalRecords" => $iTotalRecords, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => $records, "query" => $query); die(json_encode($output)); return $this; }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $form = $this->getForm("/admin/invoices/process"); $request = $this->getRequest(); $attachment = $form->getElement('attachments'); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('list', 'invoices', 'admin'); } // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/invoices/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/invoices/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); if ($form->isValid($request->getPost())) { // Get the id $id = $this->getRequest()->getParam('invoice_id'); // Set the new values if (is_numeric($id)) { $this->invoices = Doctrine::getTable('Invoices')->find($id); } // Get the values posted $params = $form->getValues(); try { $this->invoices->invoice_date = Shineisp_Commons_Utilities::formatDateIn($params['invoice_date']); $this->invoices->number = $params['number']; $this->invoices->order_id = $params['order_id']; $this->invoices->note = $params['note']; // Save the data $this->invoices->save(); $id = is_numeric($id) ? $id : $this->invoices->getIncremented(); // Update formatted_number if ($this->invoices->formatted_number != $params['formatted_number'] || empty($this->invoices->formatted_number)) { $this->invoices->formatted_number = !empty($params['formatted_number']) ? $params['formatted_number'] : Invoices::generateNumber($id); $this->invoices->save(); } } catch (Exception $e) { $this->_helper->redirector('list', 'invoices', 'admin', array('mex' => $this->translator->translate('The invoice cannot be created. Please check all your input data and try again.'), 'status' => 'danger')); } $this->_helper->redirector('edit', 'invoices', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success')); } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Invoice Edit"); $this->view->description = $this->translator->translate("Here you can edit the selected invoice."); return $this->render('applicantform'); } }
/** * addpayment * Add a payment information to a order * @param integer $orderid * @param string $transactionid * @param integer $bankid * @param boolean $status * @param float $amount */ public static function addpayment($orderid, $transactionid, $bankid, $status, $amount, $paymentdate = null, $customer_id = null, $payment_description = null) { $payment = new Payments(); // We make a double check to properly manage "null" output coming from Shineisp_Commons_Utilities::formatDateIn if (!empty($paymentdate)) { $paymentdate = Shineisp_Commons_Utilities::formatDateIn($paymentdate); } $paymentdate = !empty($paymentdate) ? $paymentdate : date('Y-m-d H:i:s'); // Set the payment data $payment->order_id = $orderid; $payment->bank_id = $bankid; $payment->reference = $transactionid; $payment->confirmed = 0; $payment->income = $amount; // Additional fields for Orders::saveAll() $payment->paymentdate = $paymentdate; $payment->customer_id = isset($customer_id) ? intval($customer_id) : intval(Orders::getCustomer($orderid)); $payment->description = isset($payment_description) ? $payment_description : null; $save = $payment->trySave(); if ($save) { Shineisp_Commons_Utilities::logs("Payments::addPayment(): save ok"); // Confirm payment, if needed. Invoices::confirm() will activate order. if ($status) { self::confirm($orderid, $status); } } return $save; }
/** * Add an item within an order * * @param Cart $item * @throws Exception * @return unknown */ public static function addOrderItem(CartItem $item) { if (empty(self::$order)) { throw new Exception('The order has not been created yet', 1000); } try { // get the item subtotals $subtotals = $item->getSubtotals(); // get the options $options = $item->getOptions(); // Get the order object previously created $order = self::$order; // add a new item $orderitem = new OrdersItems(); $orderitem->order_id = $order['order_id']; if ("domain" == $item->getType()) { // Create a new domain order item $orderitem->tld_id = !empty($options['domain']['tld']) ? $options['domain']['tld'] : null; $orderitem->parameters = json_encode($options); } else { $orderitem->product_id = $item->getId(); $orderitem->parameters = json_encode(ProductsAttributes::getSystemAttributes($item->getId())); } $orderitem->status_id = Statuses::id("tobepaid", "orders"); $orderitem->date_start = date('Y-m-d H:i:s'); $orderitem->date_end = null; $orderitem->description = $item->getName(); $orderitem->quantity = $item->getQty(); $orderitem->price = $item->getUnitprice(); $orderitem->billing_cycle_id = $item->getBillingid(); $orderitem->vat = $subtotals['taxes']; $orderitem->percentage = $subtotals['percentage']; $orderitem->uuid = $item->getUid(); // Count of the day until the expiring if ($item->getIsrecurring()) { // get the months until of the next service expiration $months = $subtotals['months']; if ($months > 0) { $totmonths = intval($item->getQty() * $months); // Calculate the total of the months $date_end = Shineisp_Commons_Utilities::add_date(date('d-m-Y H:i:s'), null, $totmonths); $orderitem->date_end = Shineisp_Commons_Utilities::formatDateIn($date_end); } else { $orderitem->date_end = null; } } $orderitem->cost = $item->getCost(); $orderitem->setupfee = $subtotals['setupfee']; $orderitem->subtotal = $subtotals['subtotal']; // Save the order item if ($orderitem->trySave()) { // Attach all the the domain to the order if ("domain" == $item->getType()) { $domain = $options['domain']['name']; $tld = $options['domain']['tld']; $domainId = Domains::Create($domain, $tld, $order->customer_id, $orderitem->detail_id); if (is_numeric($domainId)) { $ordersitemsdomains = new OrdersItemsDomains(); $ordersitemsdomains->domain_id = $domainId; $ordersitemsdomains->order_id = $order['order_id']; $ordersitemsdomains->orderitem_id = $orderitem->detail_id; $ordersitemsdomains->save(); } } // Update the totals of the order self::updateTotalsOrder($order['order_id']); return $orderitem; } } catch (Exception $e) { Shineisp_Commons_Utilities::log('There was a problem during the order creation: ' . $e->getMessage()); } return false; }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/admin/tickets/process"); $request = $this->getRequest(); $this->view->title = $this->translator->translate("New Ticket"); $this->view->description = $this->translator->translate("Here you can handle the ticket support."); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/tickets/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/tickets/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); // Check if we have a POST request if (!$request->isPost()) { $this->_helper->redirector('list', 'tickets', 'admin'); } if ($form->isValid($request->getPost())) { // Get the values posted $params = $request->getPost(); // Get the id $id = $this->getRequest()->getParam('ticket_id'); // create the ticket if not exist if (!is_numeric($id)) { $id = Tickets::saveIt(null, $params['customer_id'], $params['subject'], $params['note'], $params['category_id']); $redirector->gotoUrl("/admin/tickets/edit/id/{$id}#last"); } $date = !empty($params['datetime']) ? Shineisp_Commons_Utilities::formatDateIn($params['datetime']) : null; $note = !empty($params['note']) ? $params['note'] : null; $status = !empty($params['status_id']) && is_numeric($params['status_id']) ? $params['status_id'] : null; $sendemail = !empty($params['sendemail']) && is_numeric($params['sendemail']) ? true : false; // Save the Ticket Note and send the email to the customer $ticketNote = TicketsNotes::saveIt($id, $date, $note, $status, true, null, $sendemail); // Update the sibling if (!empty($params['sibling_id']) && is_numeric($params['sibling_id'])) { Tickets::setSibling($id, $params['sibling_id']); } // Update the operator for the selected ticket if (!empty($params['user_id']) && is_numeric($params['user_id'])) { Tickets::setOperator($id, $params['user_id']); } // Update the ticket attaching the order if (!empty($params['order_id']) && is_numeric($params['order_id'])) { Tickets::setOrder($id, $params['order_id']); } $redirector->gotoUrl("/admin/tickets/edit/id/{$id}#last"); } else { $this->view->form = $form; return $this->render('applicantform'); } }
private function servicesGrid() { $request = Zend_Controller_Front::getInstance()->getRequest(); try { if (isset($request->id) && is_numeric($request->id)) { // In order to select only the fields interested we have to add an alias to all the fields. If the aliases are not created Doctrine will require an index field for each join created. //$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' ); $rs = Products::getAllServicesByCustomerID($request->id, 'o.order_id, oi.detail_id as detail_id, pd.name as productname, DATE_FORMAT(oi.date_start, "%d/%m/%Y") AS date_start, DATE_FORMAT(oi.date_end, "%d/%m/%Y") AS date_end, DATEDIFF(oi.date_end, CURRENT_DATE) AS daysleft, oi.price as price, oi.autorenew as autorenew, oi.status_id as status'); if ($rs) { $arrStatuses = Statuses::getList('orders'); foreach ($rs as $k => $v) { if (isset($v['price'])) { //* TODO: Format price based on locale $rs[$k]['price'] = $v['price']; } if (isset($v['status']) && isset($arrStatuses[$v['status']])) { $rs[$k]['status'] = $arrStatuses[$v['status']]; } if (isset($v['autorenew'])) { $rs[$k]['autorenew'] = $v['autorenew'] == 1 ? $this->translator->translate('Yes') : $this->translator->translate('Yes'); } if (isset($v['date_start'])) { $rs[$k]['date_start'] = Shineisp_Commons_Utilities::formatDateIn($v['date_start']); } if (isset($v['date_end'])) { $rs[$k]['date_end'] = Shineisp_Commons_Utilities::formatDateIn($v['date_end']); } } $columns[] = $this->translator->translate('Product'); $columns[] = $this->translator->translate('Creation Date'); $columns[] = $this->translator->translate('Expiry Date'); $columns[] = $this->translator->translate('Days left'); $columns[] = $this->translator->translate('Price'); $columns[] = $this->translator->translate('Automatic renewal'); $columns[] = $this->translator->translate('Status'); return array('name' => 'services', 'columns' => $columns, 'records' => $rs, 'edit' => array('controller' => 'ordersitems', 'action' => 'edit'), 'pager' => true); } } } catch (Exception $e) { $this->_helper->redirector('edit', 'customers', 'admin', array('id' => $request->id, 'mex' => $this->translator->translate('Unable to process the request at this time.') . ": " . $e->getMessage(), 'status' => 'danger')); } }
/** * Save all the information about the newsletter * @param array $params */ public static function save_data($params) { if (is_numeric($params['news_id'])) { $newsletter = self::getbyId($params['news_id']); } else { $newsletter = new Newsletters(); } $newsletter['subject'] = $params['subject']; $newsletter['sendat'] = Shineisp_Commons_Utilities::formatDateIn($params['sendat']); $newsletter['sent'] = Shineisp_Commons_Utilities::formatDateIn($params['sent']); $newsletter['message'] = $params['message']; $newsletter->save(); // If the newsletter has been already sent and you'd like to send it again, clear the history if ($params['sendagain']) { NewslettersHistory::clear_queue($newsletter['news_id']); // Update the sent field value $newsletter['sent'] = null; $newsletter->save(); } // Create the queue NewslettersHistory::add_all_to_queue($newsletter['news_id']); return $newsletter['news_id']; }
/** * Save the record * * @param posted var from the form * @return Boolean */ public static function saveData($record, $id = null) { // Set the new values if (is_numeric($id)) { $panelaction = self::find($id); } else { $panelaction = new PanelsActions(); } $panelaction->action = $record['action']; $panelaction->start = Shineisp_Commons_Utilities::formatDateIn($record['start']); $panelaction->end = Shineisp_Commons_Utilities::formatDateIn($record['end']); $panelaction->log = $record['log']; $panelaction->panel_id = $record['panel_id']; $panelaction->parameters = $record['parameters']; $panelaction->status_id = $record['status_id']; if ($panelaction->trySave()) { return $panelaction->panel_id; } return false; }
/** * Save all the data * @param array $data */ public static function saveAll($id, $data) { // Set the new values if (is_numeric($id)) { $invoice = self::find($id); } else { $invoice = new PurchaseInvoices(); } $invoice['creationdate'] = Shineisp_Commons_Utilities::formatDateIn($data['creationdate']); $invoice['expiringdate'] = Shineisp_Commons_Utilities::formatDateIn($data['expiringdate']); $invoice['paymentdate'] = !empty($data['paymentdate']) ? Shineisp_Commons_Utilities::formatDateIn($data['paymentdate']) : ""; $invoice['number'] = $data['number']; $invoice['company'] = $data['company']; $invoice['category_id'] = $data['category_id']; $invoice['method_id'] = $data['method_id']; $invoice['total_net'] = $data['total_net']; $invoice['total_vat'] = $data['total_vat']; $invoice['total'] = $data['total']; $invoice['note'] = $data['note']; $invoice['status_id'] = $data['status_id']; $invoice->save(); self::UploadDocument($invoice['purchase_id']); return $invoice['purchase_id']; }
/** * Save the record * * @param posted var from the form * @return Boolean */ public static function saveData($record, $id = null) { // Set the new values if (is_numeric($id)) { $domainstasks = self::find($id); } else { $domainstasks = new DomainsTasks(); } $domainstasks->action = $record['action']; $domainstasks->startdate = Shineisp_Commons_Utilities::formatDateIn($record['startdate']); $domainstasks->enddate = Shineisp_Commons_Utilities::formatDateIn($record['enddate']); $domainstasks->registrars_id = $record['registrars_id']; $domainstasks->domain_id = $record['domain_id']; $domainstasks->status_id = $record['status_id']; if ($domainstasks->trySave()) { return $domainstasks->task_id; } return false; }
/** * chkFieldType * Check the type of the data and fix the value * @param string $value */ private function chkFieldType(array $column, $value) { if ($column['type'] == "date") { return Shineisp_Commons_Utilities::formatDateIn($value); } return $value; }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/admin/subscribers/process"); $request = $this->getRequest(); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/subscribers/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/subscribers/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('list', 'subscribers', 'admin'); } if ($form->isValid($request->getPost())) { // Get the id $id = $this->getRequest()->getParam('subscriber_id'); // Set the new values if (is_numeric($id)) { $this->subscribers = NewslettersSubscribers::getbyId($id); } // Get the values posted $params = $form->getValues(); $this->subscribers->email = $params['email']; $this->subscribers->subscriptiondate = !empty($params['subscriptiondate']) ? Shineisp_Commons_Utilities::formatDateIn($params['subscriptiondate']) : date('Y-m-d H:i:s'); $this->subscribers->save(); $id = is_numeric($id) ? $id : $this->subscribers->getIncremented(); $redirector->gotoUrl("/admin/subscribers/edit/id/{$id}"); } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Subscriber Details"); $this->view->description = $this->translator->translate("Here you can check all the submit information."); return $this->render('applicantform'); } }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $i = 0; $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/admin/services/process"); $request = $this->getRequest(); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/services/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/services/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('list', 'services', 'admin'); } if ($form->isValid($request->getPost())) { // Get the id $id = $this->getRequest()->getParam('detail_id'); // Set the new values if (is_numeric($id)) { $this->services = Doctrine::getTable('OrdersItems')->find($id); } // Get the values posted $params = $form->getValues(); $datestart = explode(" ", $params['date_start']); try { $months = BillingCycle::getMonthsNumber($params['billing_cycle_id']); if ($months > 0) { $date_end = Shineisp_Commons_Utilities::add_date($datestart[0], null, $months); } else { $date_end = null; } $this->services->date_start = Shineisp_Commons_Utilities::formatDateIn($params['date_start']); $this->services->date_end = Shineisp_Commons_Utilities::formatDateIn($date_end); $this->services->order_id = $params['order_id']; $this->services->product_id = $params['product_id']; $this->services->billing_cycle_id = $params['billing_cycle_id']; $this->services->quantity = $params['quantity']; $this->services->status_id = $params['status_id']; $this->services->setup = $params['setup']; $this->services->note = $params['note']; // Save the data $this->services->save(); $id = is_numeric($id) ? $id : $this->services->getIncremented(); // Set the autorenew OrdersItems::setAutorenew($id, $params['autorenew']); // Save the message note if (!empty($params['message'])) { $message = new Messages(); $message->dateposted = date('Y-m-d H:i:s'); $message->message = $params['message']; $message->isp_id = 1; $message->detail_id = $id; $message->save(); } // Clear the list from the DB Doctrine::getTable('OrdersItemsDomains')->findBy('orderitem_id', $id)->delete(); if ($params['domains_selected']) { $service_domains = new Doctrine_Collection('OrdersItemsDomains'); foreach ($params['domains_selected'] as $domain) { $service_domains[$i]->domain_id = $domain; $service_domains[$i]->order_id = $params['order_id']; $service_domains[$i]->orderitem_id = $id; $i++; } $service_domains->save(); } $this->_helper->redirector('edit', 'services', 'admin', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } catch (Exception $e) { $this->_helper->redirector('edit', 'services', 'admin', array('id' => $id, 'mex' => $this->translator->translate('Unable to process the request at this time.') . ": " . $e->getMessage(), 'status' => 'danger')); } $redirector->gotoUrl("/admin/services/edit/id/{$id}"); } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Service Details"); $this->view->description = $this->translator->translate("Here you can see the details of the service subscribed by the customer."); return $this->render('applicantform'); } }
/** * Save all the data * * * @param array $data */ public static function saveAll($id, $data) { // Set the new values if (is_numeric($id)) { $creditnote = self::find($id); } else { $creditnote = new CreditNotes(); } $creditnote['creationdate'] = Shineisp_Commons_Utilities::formatDateIn($data['creationdate']); $creditnote['number'] = $data['number']; $creditnote['invoice_id'] = $data['invoice_id']; $creditnote['total_net'] = $data['total_net']; $creditnote['total_vat'] = $data['total_vat']; $creditnote['total'] = $data['total']; $creditnote['note'] = $data['note']; if ($creditnote->trySave()) { if (!empty($data['description']) && !empty($data['price'])) { $creditnoteitem = new CreditNotesItems(); $creditnoteitem['creditnote_id'] = $creditnote['creditnote_id']; $creditnoteitem['quantity'] = $data['quantity']; $creditnoteitem['description'] = $data['description']; $creditnoteitem['price'] = $data['price']; $creditnoteitem['vat'] = $data['vat']; $creditnoteitem['total'] = $data['price'] + $data['vat']; $creditnoteitem->save(); } self::updateTotals($creditnote['creditnote_id']); } return $creditnote['creditnote_id']; }
/** * Save the domain information * * @param integer|null $id * @param array $params * @return Ambigous <unknown, number, NULL, mixed> */ public static function saveAll($id, $params) { if (is_numeric($id)) { $domains = Doctrine::getTable('Domains')->find($id); } else { $domains = new Domains(); } // Get the TLD information $tldInfo = DomainsTlds::getAllInfo($params['tld_id']); $params['creation_date'] = empty($params['creation_date']) ? date('Y-m-d') : Shineisp_Commons_Utilities::formatDateIn($params['creation_date']); // Set the new values $domains->domain = $params['domain']; if (isset($tldInfo['WhoisServers'])) { $domains->tld = $tldInfo['WhoisServers']['tld']; } $domains->tld_id = $params['tld_id']; $domains->authinfocode = $params['authinfocode']; $domains->creation_date = $params['creation_date']; $domains->modification_date = date('Y-m-d'); if (!empty($params['expiring_date'])) { $domains->expiring_date = Shineisp_Commons_Utilities::formatDateIn($params['expiring_date']); } $domains->customer_id = $params['customer_id']; $domains->note = $params['note']; $domains->registrars_id = !empty($params['registrars_id']) ? $params['registrars_id'] : Null; $domains->status_id = $params['status_id'] ? $params['status_id'] : null; // Save the data if ($domains->trySave()) { $id = is_numeric($id) ? $id : $domains->getIncremented(); return $id; } return false; }
/** * saveAll * Save all the data * @param $params * @return Boolean */ public static function saveAll($id, $params) { $date_end = null; if (!is_array($params)) { return false; } $details = Doctrine::getTable('OrdersItems')->find($id); // Generic price setting $rowtotal = $params['price']; $vat = null; $percentage = null; // Get the taxes applied $tax = Taxes::getTaxbyProductID($params['product_id']); if ($tax['percentage'] > 0) { $rowtotal = $params['price'] * (100 + $tax['percentage']) / 100; $vat = $params['price'] * $tax['percentage'] / 100; $percentage = $tax['percentage']; } else { if (!empty($params['parameters'])) { // it is a domain $domainparams = json_decode($params['parameters'], true); if (!empty($domainparams['domain']['tld'])) { $tax = Taxes::getTaxbyTldID($domainparams['domain']['tld']); if ($tax['percentage'] > 0) { $vat = $params['price'] * $tax['percentage'] / 100; $percentage = $tax['percentage']; $rowtotal = $params['price'] * (100 + $tax['percentage']) / 100; } } } } if (!empty($params['billing_cycle_id'])) { $months = BillingCycle::getMonthsNumber($params['billing_cycle_id']); } if ($months > 0 && is_numeric($params['product_id']) && $params['product_id'] > 0) { // only for the product and services. Domains excluded $rowtotal = $rowtotal * $months; } $params['date_end'] = Shineisp_Commons_Utilities::add_date($params['date_start'], null, $months); $details->quantity = $params['quantity']; $details->date_start = Shineisp_Commons_Utilities::formatDateIn($params['date_start']); $details->date_end = Shineisp_Commons_Utilities::formatDateIn($params['date_end']); $details->billing_cycle_id = !empty($params['billing_cycle_id']) ? $params['billing_cycle_id'] : null; $details->price = $params['price']; $details->vat = $vat; $details->percentage = $percentage; $details->cost = $params['cost']; $details->product_id = is_numeric($params['product_id']) && $params['product_id'] > 0 ? $params['product_id'] : NULL; $details->setupfee = $params['setupfee']; $details->discount = $params['discount']; $details->subtotal = $rowtotal * $params['quantity']; $details->status_id = $params['status_id']; $details->description = $params['description']; $details->parameters = $params['parameters']; if ($details->trySave()) { OrdersItems::setAutorenew($id, $params['autorenew']); // Remove all domains OrdersItemsDomains::removeAllDomains($id); if ($params['domains_selected']) { foreach ($params['domains_selected'] as $domain) { OrdersItemsDomains::addDomain($details['order_id'], $domain); } } return true; } return false; }
/** * Save all the data in the database * @param array $data * @param integer $id */ public static function saveAll(array $data, $id, $userId) { if (!empty($data) && is_array($data)) { if (is_numeric($id)) { $note = Doctrine::getTable('Notes')->find($id); if ($note->user_id != $userId) { return false; } } else { $note = new Notes(); $note->created = date('Y-m-d H:i:s'); } $note->name = $data['name']; $note->note = $data['note']; $note->user_id = $userId; $note->changed = date('Y-m-d H:i:s'); $note->expire = !empty($data['expire']) ? Shineisp_Commons_Utilities::formatDateIn($data['expire']) : null; $note->save(); return $note['note_id']; } return false; }