Inheritance: extends AppModel
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'order_invoice';
        $this->className = 'OrderInvoice';
        $this->addRowAction('view');
        $this->context = Context::getContext();
        $this->_select = '`id_order_invoice` AS `id_invoice`,
		`id_order_invoice` AS `outstanding`,
		CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
		c.`outstanding_allow_amount`,
		r.`color`,
		rl.`name` AS `risk`';
        $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.`id_order` = a.`id_order`)
		LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (c.`id_customer` = o.`id_customer`)
		LEFT JOIN `' . _DB_PREFIX_ . 'risk` r ON (r.`id_risk` = c.`id_risk`)
		LEFT JOIN `' . _DB_PREFIX_ . 'risk_lang` rl ON (r.`id_risk` = rl.`id_risk` AND rl.`id_lang` = ' . (int) $this->context->language->id . ')';
        $this->_where = 'AND number > 0';
        $risks = array();
        foreach (Risk::getRisks() as $risk) {
            $risks[$risk->id] = $risk->name;
        }
        $this->fields_list = array('number' => array('title' => $this->l('Invoice')), 'date_add' => array('title' => $this->l('Date'), 'type' => 'date', 'align' => 'right', 'filter_key' => 'a!date_add'), 'customer' => array('title' => $this->l('Customer'), 'filter_key' => 'customer', 'tmpTableFilter' => true), 'company' => array('title' => $this->l('Company'), 'align' => 'center'), 'risk' => array('title' => $this->l('Risk'), 'align' => 'center', 'orderby' => false, 'type' => 'select', 'color' => 'color', 'list' => $risks, 'filter_key' => 'r!id_risk', 'filter_type' => 'int'), 'outstanding_allow_amount' => array('title' => $this->l('Outstanding Allow'), 'align' => 'center', 'prefix' => '<b>', 'suffix' => '</b>', 'type' => 'price'), 'outstanding' => array('title' => $this->l('Current Outstanding'), 'align' => 'center', 'callback' => 'printOutstandingCalculation', 'orderby' => false, 'search' => false), 'id_invoice' => array('title' => $this->l('Invoice'), 'align' => 'center', 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
        parent::__construct();
    }
 public function renderForm()
 {
     /** @var Customer $obj */
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $genders = Gender::getGenders();
     $list_genders = array();
     foreach ($genders as $key => $gender) {
         /** @var Gender $gender */
         $list_genders[$key]['id'] = 'gender_' . $gender->id;
         $list_genders[$key]['value'] = $gender->id;
         $list_genders[$key]['label'] = $gender->name;
     }
     $years = Tools::dateYears();
     $months = Tools::dateMonths();
     $days = Tools::dateDays();
     $groups = Group::getGroups($this->default_form_language, true);
     $this->fields_form = array('legend' => array('title' => $this->l('Customer'), 'icon' => 'icon-user'), 'input' => array(array('type' => 'radio', 'label' => $this->l('Social title'), 'name' => 'id_gender', 'required' => false, 'class' => 't', 'values' => $list_genders), array('type' => 'text', 'label' => $this->l('First name'), 'name' => 'firstname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"°{}_$%:'), array('type' => 'text', 'label' => $this->l('Last name'), 'name' => 'lastname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"°{}_$%:'), array('type' => 'text', 'prefix' => '<i class="icon-envelope-o"></i>', 'label' => $this->l('Email address'), 'name' => 'email', 'col' => '4', 'required' => true, 'autocomplete' => false), array('type' => 'password', 'label' => $this->l('Password'), 'name' => 'passwd', 'required' => $obj->id ? false : true, 'col' => '4', 'hint' => $obj->id ? $this->l('Leave this field blank if there\'s no change.') : sprintf($this->l('Password should be at least %s characters long.'), Validate::PASSWORD_LENGTH)), array('type' => 'birthday', 'label' => $this->l('Birthday'), 'name' => 'birthday', 'options' => array('days' => $days, 'months' => $months, 'years' => $years)), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Enable or disable customer login.')), array('type' => 'switch', 'label' => $this->l('Newsletter'), 'name' => 'newsletter', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'newsletter_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'newsletter_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_NWSL')), 'hint' => $this->l('This customer will receive your newsletter via email.')), array('type' => 'switch', 'label' => $this->l('Opt-in'), 'name' => 'optin', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'optin_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'optin_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_OPTIN')), 'hint' => $this->l('This customer will receive your ads via email.'))));
     // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups
     if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) {
         $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
         $guest_group = Configuration::get('PS_GUEST_GROUP');
         foreach ($groups as $key => $g) {
             if (in_array($g['id_group'], array($visitor_group, $guest_group))) {
                 unset($groups[$key]);
             }
         }
     }
     $this->fields_form['input'] = array_merge($this->fields_form['input'], array(array('type' => 'group', 'label' => $this->l('Group access'), 'name' => 'groupBox', 'values' => $groups, 'required' => true, 'col' => '6', 'hint' => $this->l('Select all the groups that you would like to apply to this customer.')), array('type' => 'select', 'label' => $this->l('Default customer group'), 'name' => 'id_default_group', 'options' => array('query' => $groups, 'id' => 'id_group', 'name' => 'name'), 'col' => '4', 'hint' => array($this->l('This group will be the user\'s default group.'), $this->l('Only the discount for the selected group will be applied to this customer.')))));
     // if customer is a guest customer, password hasn't to be there
     if ($obj->id && ($obj->is_guest && $obj->id_default_group == Configuration::get('PS_GUEST_GROUP'))) {
         foreach ($this->fields_form['input'] as $k => $field) {
             if ($field['type'] == 'password') {
                 array_splice($this->fields_form['input'], $k, 1);
             }
         }
     }
     if (Configuration::get('PS_B2B_ENABLE')) {
         $risks = Risk::getRisks();
         $list_risks = array();
         foreach ($risks as $key => $risk) {
             /** @var Risk $risk */
             $list_risks[$key]['id_risk'] = (int) $risk->id;
             $list_risks[$key]['name'] = $risk->name;
         }
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('SIRET'), 'name' => 'siret');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('APE'), 'name' => 'ape');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Website'), 'name' => 'website');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Allowed outstanding amount'), 'name' => 'outstanding_allow_amount', 'hint' => $this->l('Valid characters:') . ' 0-9', 'suffix' => $this->context->currency->sign);
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Maximum number of payment days'), 'name' => 'max_payment_days', 'hint' => $this->l('Valid characters:') . ' 0-9');
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Risk rating'), 'name' => 'id_risk', 'required' => false, 'class' => 't', 'options' => array('query' => $list_risks, 'id' => 'id_risk', 'name' => 'name'));
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     $birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
     $this->fields_value = array('years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0, 'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0, 'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0);
     // Added values of object Group
     if (!Validate::isUnsignedId($obj->id)) {
         $customer_groups = array();
     } else {
         $customer_groups = $obj->getGroups();
     }
     $customer_groups_ids = array();
     if (is_array($customer_groups)) {
         foreach ($customer_groups as $customer_group) {
             $customer_groups_ids[] = $customer_group;
         }
     }
     // if empty $carrier_groups_ids : object creation : we set the default groups
     if (empty($customer_groups_ids)) {
         $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
         $customer_groups_ids = array_merge($customer_groups_ids, $preselected);
     }
     foreach ($groups as $group) {
         $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $customer_groups_ids));
     }
     return parent::renderForm();
 }
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $genders = Gender::getGenders();
     $list_genders = array();
     foreach ($genders as $key => $gender) {
         $list_genders[$key]['id'] = 'gender_' . $gender->id;
         $list_genders[$key]['value'] = $gender->id;
         $list_genders[$key]['label'] = $gender->name;
     }
     $years = Tools::dateYears();
     $months = Tools::dateMonths();
     $days = Tools::dateDays();
     $groups = Group::getGroups($this->default_form_language, true);
     $this->fields_form = array('legend' => array('title' => $this->l('Customer'), 'image' => '../img/admin/tab-customers.gif'), 'input' => array(array('type' => 'radio', 'label' => $this->l('Titles:'), 'name' => 'id_gender', 'required' => false, 'class' => 't', 'values' => $list_genders), array('type' => 'text', 'label' => $this->l('First name:'), 'name' => 'firstname', 'size' => 33, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:'), array('type' => 'text', 'label' => $this->l('Last name:'), 'name' => 'lastname', 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:'), array('type' => 'text', 'label' => $this->l('E-mail address:'), 'name' => 'email', 'size' => 33, 'required' => true), array('type' => 'password', 'label' => $this->l('Password:'******'name' => 'passwd', 'size' => 33, 'required' => $obj->id ? false : true, 'desc' => $obj->id ? $this->l('Leave blank if no change') : $this->l('5 characters min., only letters, numbers, or') . ' -_'), array('type' => 'birthday', 'label' => $this->l('Birthday:'), 'name' => 'birthday', 'options' => array('days' => $days, 'months' => $months, 'years' => $years)), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Allow or disallow this customer to log in')), array('type' => 'radio', 'label' => $this->l('Newsletter:'), 'name' => 'newsletter', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'newsletter_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'newsletter_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Customer will receive your newsletter via e-mail')), array('type' => 'radio', 'label' => $this->l('Opt-in:'), 'name' => 'optin', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'optin_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'optin_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Customer will receive your ads via e-mail'))));
     // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups
     if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) {
         $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
         $guest_group = Configuration::get('PS_GUEST_GROUP');
         foreach ($groups as $key => $g) {
             if (in_array($g['id_group'], array($visitor_group, $guest_group))) {
                 unset($groups[$key]);
             }
         }
     }
     $this->fields_form['input'] = array_merge($this->fields_form['input'], array(array('type' => 'group', 'label' => $this->l('Group access:'), 'name' => 'groupBox', 'values' => $groups, 'required' => true, 'desc' => $this->l('Select all customer groups you would like to apply to this customer')), array('type' => 'select', 'label' => $this->l('Default customer group:'), 'name' => 'id_default_group', 'options' => array('query' => $groups, 'id' => 'id_group', 'name' => 'name'), 'hint' => $this->l('The group will be as applied by default.'), 'desc' => $this->l('Apply the discount\'s price of this group.'))));
     // if customer is a guest customer, password hasn't to be there
     if ($obj->id && ($obj->is_guest && $obj->id_default_group == Configuration::get('PS_GUEST_GROUP'))) {
         foreach ($this->fields_form['input'] as $k => $field) {
             if ($field['type'] == 'password') {
                 array_splice($this->fields_form['input'], $k, 1);
             }
         }
     }
     if (Configuration::get('PS_B2B_ENABLE')) {
         $risks = Risk::getRisks();
         $list_risks = array();
         foreach ($risks as $key => $risk) {
             $list_risks[$key]['id_risk'] = (int) $risk->id;
             $list_risks[$key]['name'] = $risk->name;
         }
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Company:'), 'name' => 'company', 'size' => 33);
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('SIRET:'), 'name' => 'siret', 'size' => 14);
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('APE:'), 'name' => 'ape', 'size' => 5);
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Website:'), 'name' => 'website', 'size' => 33);
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Outstanding allowed:'), 'name' => 'outstanding_allow_amount', 'size' => 10, 'hint' => $this->l('Valid characters:') . ' 0-9', 'suffix' => '¤');
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Max payment days:'), 'name' => 'max_payment_days', 'size' => 10, 'hint' => $this->l('Valid characters:') . ' 0-9');
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Risk:'), 'name' => 'id_risk', 'required' => false, 'class' => 't', 'options' => array('query' => $list_risks, 'id' => 'id_risk', 'name' => 'name'));
     }
     $this->fields_form['submit'] = array('title' => $this->l('   Save   '), 'class' => 'button');
     $birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
     $this->fields_value = array('years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0, 'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0, 'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0);
     // Added values of object Group
     $customer_groups = $obj->getGroups();
     $customer_groups_ids = array();
     if (is_array($customer_groups)) {
         foreach ($customer_groups as $customer_group) {
             $customer_groups_ids[] = $customer_group;
         }
     }
     // if empty $carrier_groups_ids : object creation : we set the default groups
     if (empty($customer_groups_ids)) {
         $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
         $customer_groups_ids = array_merge($customer_groups_ids, $preselected);
     }
     foreach ($groups as $group) {
         $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $customer_groups_ids));
     }
     return parent::renderForm();
 }
 /**
  * Deletes rows for the model
  */
 public function actionDelete()
 {
     $admin = new Admin(Risk::model(), $this);
     $admin->deleteModel();
 }
Example #5
0
 /**
  * Updating Patient Risk details.
  *
  * @param type $risk_name
  * @param type $risk_value
  */
 protected function updateRisk($risk_name, $risk_value)
 {
     $risk_check = $risk_name === 'anticoagulant' ? 'Anticoagulants' : 'Alpha blockers';
     $risk = \Risk::model()->find('name=?', array($risk_check));
     $criteria = new \CDbCriteria();
     $criteria->compare('risk_id', $risk['id']);
     $criteria->compare('patient_id', $this->patient->id);
     $patient_risk = \PatientRiskAssignment::model()->find($criteria);
     if ($risk_value === '1') {
         $patient_risk = !$patient_risk ? new \PatientRiskAssignment() : $patient_risk;
         $patient_risk->risk_id = $risk['id'];
         $patient_risk->patient_id = $this->patient->id;
         $patient_risk->save();
     } elseif ($patient_risk && $risk_value === '2') {
         \PatientRiskAssignment::model()->deleteByPk($patient_risk->id);
     }
 }
Example #6
0
 /**
  * List of risks.
  */
 public function riskList()
 {
     $risk_ids = array();
     foreach ($this->patient->risks as $risk) {
         if ($risk->name != 'Other') {
             $risk_ids[] = $risk->id;
         }
     }
     $criteria = new CDbCriteria();
     !empty($risk_ids) && $criteria->addNotInCondition('id', $risk_ids);
     $criteria->order = 'name asc';
     return Risk::model()->active()->findAll($criteria);
 }