public static function saveAll($data, $product_id)
 {
     if (empty($data['group_id'])) {
         return false;
     }
     $i = 0;
     $attrs = new Doctrine_Collection('ProductsAttributesIndexes');
     self::deleteAll($product_id);
     // Get all the product attributes
     $attributes = ProductsAttributesGroups::getAttributesProfiles($data['group_id']);
     // Loop of the posted variables
     foreach ($data as $var => $value) {
         // Loop of all the attributes
         foreach ($attributes as $attribute) {
             if ($attribute['ProductsAttributes']['code'] == $var) {
                 $attrs[$i]->product_id = $product_id;
                 $attrs[$i]->attribute_id = $attribute['attribute_id'];
                 $attrs[$i]->value = $value;
                 $i++;
             }
         }
     }
     $attrs->save();
 }
 /**
  * editAction
  * Get a record and populate the application form 
  * @return unknown_type
  */
 public function editAction()
 {
     $Session = new Zend_Session_Namespace('Admin');
     $form = $this->getForm('/admin/productsattributesgroups/process');
     $id = $this->getRequest()->getParam('id');
     // 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/productsattributesgroups/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/productsattributesgroups/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     if (!empty($id) && is_numeric($id)) {
         $rs = $this->productsattributesgroups->getAllInfo($id, "group_id, name, isrecurring, iscomparable", $Session->langid);
         if (!empty($rs)) {
             $this->view->id = $id;
             // Get all the attributes for the product selected.
             $rs['attributes'] = ProductsAttributesGroups::getAttributes($id);
             $form->populate($rs);
             $this->view->buttons[] = array("url" => "/admin/productsattributesgroups/confirm/id/{$id}", "label" => $this->translator->translate('Delete'), "params" => array('css' => null));
         }
     }
     $this->view->title = $this->translator->translate("Attribute Group");
     $this->view->description = $this->translator->translate("Here you can edit the attribute group details.");
     $this->view->mex = $this->getRequest()->getParam('mex');
     $this->view->mexstatus = $this->getRequest()->getParam('status');
     $this->view->form = $form;
     $this->render('applicantform');
 }
 /**
  * Add a group attribute
  * 
  * @param string $name
  * @param boolean $is_recurring
  * @param boolean $is_comparable
  */
 public static function addNew($id = NULL, $name, $is_recurring = 0, $is_comparable = 0)
 {
     if (is_numeric($id)) {
         $group = self::find($id);
     } else {
         $group = new ProductsAttributesGroups();
     }
     $group['name'] = $name;
     $group['code'] = Shineisp_Commons_UrlRewrites::format($name);
     $group['isrecurring'] = $is_recurring;
     $group['iscomparable'] = $is_comparable;
     $group->save();
     return $group['group_id'];
 }
Example #4
0
 /**
  * Get the list of the attributes group
  * 
  *  
  * @param integer $index
  */
 public static function getGroups($index)
 {
     $items = array();
     $groups = ProductsAttributesGroups::getGroups($index);
     foreach ($groups as $group) {
         if (!empty($group['ProductsAttributesGroups']['name'])) {
             $items[] = "<a href='/admin/productsattributesgroups/edit/id/" . $group['group_id'] . "'>" . $group['ProductsAttributesGroups']['name'] . "</a>";
         }
     }
     return implode(", ", $items);
 }
Example #5
0
 /**
  * Create the attribute elements
  * 
  * 
  * @param integer $attribute_group_id
  */
 private function createAttributesElements($form, $group_id)
 {
     $attributeForm = new Zend_Form_SubForm();
     $attributeForm->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator');
     if (is_numeric($group_id)) {
         // Get all the elements
         $elements = ProductsAttributesGroups::getAttributesProfiles($group_id, $this->session->langid);
         if (!empty($elements[0])) {
             foreach ($elements as $element) {
                 if (!empty($element['ProductsAttributes'])) {
                     // Check the label
                     $label = !empty($element['ProductsAttributes']['ProductsAttributesData'][0]['label']) ? $element['ProductsAttributes']['ProductsAttributesData'][0]['label'] : $element['ProductsAttributes']['code'];
                     $description = !empty($element['ProductsAttributes']['ProductsAttributesData'][0]['description']) ? $element['ProductsAttributes']['ProductsAttributesData'][0]['description'] : "";
                     // Create the element
                     $attributeForm->addElement($element['ProductsAttributes']['type'], $element['ProductsAttributes']['code'], array('label' => $label, 'class' => 'form-control', 'decorators' => array('Composite'), 'description' => $description));
                     if ($element['ProductsAttributes']['is_required']) {
                         $attributeForm->getElement($element['ProductsAttributes']['code'])->setRequired(true);
                     }
                     // Handle the default option items for the dropdown selector
                     if ($element['ProductsAttributes']['type'] == "select") {
                         $data = !empty($element['ProductsAttributes']['defaultvalue']) ? json_decode($element['ProductsAttributes']['defaultvalue'], true) : array();
                         $attributeForm->getElement($element['ProductsAttributes']['code'])->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions($data);
                     } else {
                         $attributeForm->getElement($element['ProductsAttributes']['code'])->setValue($element['ProductsAttributes']['defaultvalue']);
                     }
                 }
             }
             $form->addSubForm($attributeForm, 'attributes');
         }
     }
     return $form;
 }
Example #6
0
 public function init()
 {
     // Set the custom decorator
     $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator');
     $translate = Shineisp_Registry::get('Zend_Translate');
     $this->addElement('text', 'name', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Product name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'nickname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Product Nickname'), 'description' => $translate->_('This is the short name of the product'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'uri', array('filters' => array('StringTrim'), 'label' => $translate->_('URI'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'sku', array('filters' => array('StringTrim'), 'label' => $translate->_('SKU'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('textarea', 'shortdescription', array('filters' => array('StringTrim'), 'label' => $translate->_('Short Description'), 'id' => 'shortdescription', 'class' => 'col-lg-12 form-control wysiwyg'));
     $this->addElement('textarea', 'metakeywords', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Keywords'), 'rows' => 5, 'class' => 'col-lg-12 form-control'));
     $this->addElement('textarea', 'metadescription', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Meta Description'), 'rows' => 5, 'class' => 'col-lg-12 form-control'));
     $this->addElement('textarea', 'description', array('filters' => array('StringTrim'), 'label' => $translate->_('Description'), 'id' => 'description', 'class' => 'col-lg-12 form-control wysiwyg'));
     $this->addElement('select', 'category_id', array('label' => $translate->_('Category'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(ProductsCategories::getList());
     $this->addElement('select', 'welcome_mail_id', array('label' => $translate->_('Welcome E-Mail'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('welcome_mail_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(EmailsTemplates::getList());
     $this->addElement('select', 'server_group_id', array('label' => $translate->_('Server group'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('server_group_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(ServersGroups::getList(true));
     $this->addElement('select', 'autosetup', array('label' => $translate->_('Automatic setup'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('autosetup')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(array('0' => 'Do not automatically setup this product', '1' => 'Automatically setup the product as soon as an order is placed', '2' => 'Automatically setup the product as soon as the first payment is received', '3' => 'Automatically setup the product when you manually accept a pending order', '4' => 'Automatically setup the product as soon as the payment is complete'));
     $this->addElement('multiselect', 'related', array('label' => $translate->_('Related Products'), 'decorators' => array('Bootstrap'), 'size' => '20x', 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4'));
     $this->addElement('multiselect', 'upgrade', array('label' => $translate->_('Product Upgrades'), 'decorators' => array('Bootstrap'), 'size' => '20x', 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4'));
     $this->getElement('related')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Products::getList());
     $this->getElement('upgrade')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Products::getList());
     $this->addElement('select', 'tax_id', array('label' => 'Tax', 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('tax_id')->setAllowEmpty(false)->setMultiOptions(Taxes::getList(true));
     $this->addElement('text', 'cost', array('filters' => array('StringTrim'), 'label' => $translate->_('Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'price_1', array('filters' => array('StringTrim'), 'label' => $translate->_('Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'setupfee', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup Fee'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('textarea', 'setup', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('XML Setup Configuration. See the manual'), 'class' => 'col-lg-12 form-control'));
     $this->addElement('select', 'enabled', array('label' => $translate->_('Enabled'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'Disabled', '1' => 'Active')));
     $this->addElement('select', 'ishighlighted', array('label' => $translate->_('Is Highlighted'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes')));
     $this->addElement('select', 'isrefundable', array('label' => $translate->_('Is Refundable'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes')));
     $this->addElement('select', 'default', array('label' => $translate->_('Default Image'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes')));
     $this->addElement('select', 'iscomparable', array('label' => $translate->_('Is Comparable'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes')));
     $this->addElement('select', 'showonrss', array('label' => $translate->_('Publish on RSS Feed'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes')));
     $this->addElement('select', 'downgradable', array('label' => $translate->_('Allow downgrades'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes')));
     $this->addElement('select', 'type', array('label' => $translate->_('Product Type'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('generic' => $translate->_('Generic'), 'domain' => $translate->_('Domain'), 'hosting' => $translate->_('Hosting'))));
     // If the browser client is an Apple client hide the file upload html object
     if (false == Shineisp_Commons_Utilities::isAppleClient()) {
         $this->addElement('text', 'filedescription', array('filters' => array('StringTrim'), 'label' => $translate->_('Description'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
         $MBlimit = Settings::findbyParam('adminuploadlimit');
         $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit);
         $filetypes = Settings::findbyParam('adminuploadfiletypes', 'Admin');
         $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $filetypes, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle'));
         $file->addValidator('Extension', false, $filetypes)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1);
         $this->addElement($file);
     }
     $this->addElement('multiselect', 'wikipages', array('label' => $translate->_('Wiki Pages'), 'decorators' => array('Bootstrap'), 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4'));
     $this->getElement('wikipages')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Wiki::getList());
     $this->addElement('select', 'tranche_billing_cycle_id', array('label' => $translate->_('Billing Cycle'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('tranche_billing_cycle_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(BillingCycle::getList());
     $this->addElement('text', 'tranche_qty', array('filters' => array('StringTrim'), 'label' => $translate->_('Quantity'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'tranche_measure', array('filters' => array('StringTrim'), 'label' => $translate->_('Measurement label'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'tranche_setupfee', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup fee'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('text', 'tranche_price', array('filters' => array('StringTrim'), 'label' => $translate->_('Unit Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('multiselect', 'tranche_includes_domains', array('isArray' => true, 'label' => $translate->_('Domain included'), 'decorators' => array('Bootstrap'), 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4'));
     $this->getElement('tranche_includes_domains')->setAllowEmpty(true)->setRegisterInArrayValidator(false)->setMultiOptions(DomainsTlds::getList());
     $this->addElement('select', 'group_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Attribute Group'), 'required' => true, 'class' => 'form-control'));
     $this->getElement('group_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(ProductsAttributesGroups::getList());
     $this->addElement('text', 'position', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Position'), 'class' => 'form-control'));
     $this->addElement('textarea', 'blocks', array('filters' => array('StringTrim'), 'label' => $translate->_('Blocks'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control'));
     $this->addElement('hidden', 'product_id');
 }
Example #7
0
 /**
  * showAction
  * Create the reports page
  */
 public function showAction()
 {
     $request = $this->getRequest();
     $datatype = $request->getParam('type');
     $param = $request->getParam('q');
     $autorenew = 1;
     $links = "";
     switch ($datatype) {
         case 'profitofyear':
             if (is_numeric($param)) {
                 $links = $this->translator->_("Click one of these links to show the economic reports");
                 $years = Invoices::getYears();
                 foreach ($years as $year) {
                     $links .= " <a href='/admin/reports/show/type/profitofyear/q/{$year}'>{$year}</a>";
                 }
                 $this->view->title = $this->translator->_("Estimated Revenue for %s", $param);
                 if (!empty($years)) {
                     $this->view->description = $this->translator->_("Below is the economic summary of the %s.", $param) . " " . $links;
                 } else {
                     $this->view->description = $this->translator->_("Below is the economic summary of the %s.", $param);
                 }
                 $this->view->year = $param;
                 $graph = new Shineisp_Commons_Morris();
                 // Get the total of the revenues per year
                 $graphdata = $graph->setType('Area')->setData(Orders::prepareGraphData(array($param), 'month', false))->setElement('graph')->setXkey('xdata')->setLabels(array($this->translator->translate('Net Revenue (Taxable Income less Costs)')))->setOptions(array('lineColors' => array('#428BCA'), 'preUnits' => Settings::findbyParam('currency') . " "))->plot();
                 $this->view->placeholder("admin_endbody")->append($graphdata);
                 Invoices::getSummaryGrid($this->_helper, $param);
                 PurchaseInvoices::getSummaryGrid($this->_helper, $param);
             } else {
                 $this->_helper->redirector('show', 'reports', 'admin', array('type' => 'profitofyear', 'q' => date('Y')));
             }
             break;
         case 'productsummary':
             $years = Invoices::getYears();
             foreach ($years as $year) {
                 $links .= " <a href='/admin/reports/show/type/productsummary/q/{$year}'>{$year}</a>";
             }
             if (!empty($years)) {
                 $this->view->description = $this->translator->_("In this list you can see the summary of the products sold. %s", $param) . " <br/> " . $links . " <a href='/admin/reports/show/type/productsummary/'>" . $this->translator->translate('Show All') . "</a> ";
             } else {
                 $this->view->description = $this->translator->_("In this list you can see the summary of the products sold. %s", $param);
             }
             $this->view->title = $this->translator->translate("Products summary");
             $this->view->data = array('records' => Products::getBestseller($param));
             break;
         case 'tldsummarypermonth':
             $this->view->title = $this->translator->translate("Domain TLD monthly summary");
             $this->view->description = $this->translator->translate("In this list you can see the summary of the TLD per month.");
             $graph = new Shineisp_Commons_Morris();
             $data = Domains::prepareGraphDataperMonth();
             if (!empty($data)) {
                 // Get the total of the revenues per year
                 $graphdata = $graph->setType('Bar')->setData($data)->setElement('graph')->setXkey('xdata')->setLabels(array_keys($data['tld']))->plot();
                 $this->view->placeholder("admin_endbody")->append($graphdata);
             }
             $this->view->data = array('records' => Domains::getSummaryPerMonth());
             break;
         case 'domainstats':
             $this->view->title = $this->translator->translate("Domain stats");
             $this->view->description = $this->translator->translate("This list shows all the costs and earnings of the domains sold grouped by tld.");
             $graph = new Shineisp_Commons_Morris();
             // Get the tlds domains per type
             $graphdata = $graph->setType('Donut')->setData(Domains::prepareGraphData())->setElement('graph')->plot();
             $this->view->placeholder("admin_endbody")->append($graphdata);
             $this->view->data = array('records' => Domains::getSummary());
             break;
         case 'tldsummaryowner':
             $this->view->title = $this->translator->translate("Summary per client");
             $this->view->description = $this->translator->translate("By this list you can see the summary of the domains bought per client.");
             $this->view->data = array('records' => Domains::domains_per_customers(), 'pager' => true);
             break;
         case 'domainstasks':
             $this->view->title = $this->translator->translate("List of all domain tasks (last 100 records)");
             $this->view->description = $this->translator->translate("By this list you can know all the tasks for each created domain.");
             $this->view->graph = "";
             $this->view->data = array('records' => DomainsTasks::GetTask(100), 'delete' => array('controller' => 'reports', 'action' => 'deletetask'), 'pager' => true);
             break;
         case 'servicesummary':
             // get all the recurring products and services as default
             $groups = ProductsAttributesGroups::getList(null, true);
             if (!empty($groups)) {
                 $groups = array_keys($groups);
             }
             $groups = array('3', '9');
             $fields = "detail_id,\n\t\t\t\t\t\t\to.order_id as orderid,\n\t\t\t\t\t\t\tc.customer_id as customer_id,  \n\t\t\t\t\t\t\toid.relationship_id as relationship_id,\n\t\t\t\t\t\t\tDATE_FORMAT(oi.date_end, '%d/%m/%Y') as expiringdate,\n\t\t\t\t\t\t\td.autorenew as autorenew,\n\t\t\t\t\t\t\tCONCAT(c.firstname, ' ', c.lastname, ' ', c.company) as customer,\n\t\t\t\t\t\t\toi.description as description,\n\t\t\t\t\t\t\tCONCAT(d.domain, '.', d.tld) as domain,  \n\t\t\t\t\t\t\toi.cost as cost, \n\t\t\t\t\t\t\toi.price as price";
             $this->view->title = $this->translator->translate("List of the recurring services");
             $this->view->description = $this->translator->translate("By this list you can see the summary of the services bought per client.");
             $this->view->graph = "";
             $this->view->data = array('records' => OrdersItems::getAllRecurringServices($fields, $groups), 'pager' => true);
             break;
         case 'ticketsummary':
             $this->view->title = $this->translator->translate("Ticket summary");
             $this->view->description = $this->translator->translate("List of the last help requests.");
             $this->view->graph = "";
             $this->view->data = array('records' => Tickets::Last(), 'actions' => array('/admin/tickets/edit/id/' => 'show'), 'pager' => true);
             break;
         case 'domainsexpiration':
             $this->view->title = $this->translator->translate("Expiration list of domains");
             $this->view->description = $this->translator->translate("This view helps you to check which are the domains next to expiration.");
             $this->view->graph = "";
             $this->view->data = array('records' => Domains::getExpiringDomains(), 'actions' => array('/admin/domains/edit/id/' => 'show'), 'pager' => true);
             break;
         case 'servicesexpiration':
             $this->view->title = $this->translator->translate("Expiration list of services");
             $this->view->description = $this->translator->translate("This view helps you to check which are the services next to expiration.");
             $this->view->graph = "";
             $this->view->data = array('records' => Products::getExpiringProducts(), 'actions' => array('/admin/services/edit/id/' => 'show'), 'pager' => true);
             break;
         default:
             $this->_helper->redirector('show', 'reports', 'admin', array('type' => 'profitofyear', 'q' => date('Y')));
             break;
     }
 }