Esempio n. 1
0
 /**
  * Check validation
  *
  * @param   string  $users_info_id  not used
  *
  * @return bool
  */
 public function chkvalidation($users_info_id)
 {
     $model = $this->getModel('checkout');
     $billingaddresses = $model->billingaddresses();
     $shippingaddresses = $model->shipaddress($users_info_id);
     $extra_field = new extra_field();
     $extrafield_name = '';
     $return = 0;
     if (!$billingaddresses->is_company) {
         if ($billingaddresses->firstname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_FIRST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         } elseif ($billingaddresses->lastname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_LAST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         }
     } else {
         if ($billingaddresses->company_name == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_COMPANY_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         }
         if ($billingaddresses->firstname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_FIRST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         } elseif ($billingaddresses->lastname == '') {
             $return = 1;
             $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_LAST_NAME');
             JError::raiseWarning('', $msg);
             return $return;
         } elseif (ECONOMIC_INTEGRATION == 1 && trim($billingaddresses->ean_number) != '') {
             $economic = new economic();
             $debtorHandle = $economic->createUserInEconomic($billingaddresses);
             if (JError::isError(JError::getError())) {
                 $return = 1;
                 $error = JError::getError();
                 $msg = $error->message;
                 JError::raiseWarning('', $msg);
                 return $return;
             }
         }
     }
     if (!trim($billingaddresses->address)) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_ADDRESS');
         JError::raiseWarning('', $msg);
         return $return;
     } elseif (!$billingaddresses->country_code) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_SELECT_COUNTRY');
         JError::raiseWarning('', $msg);
         return $return;
     } elseif (!$billingaddresses->zipcode) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_ZIPCODE');
         JError::raiseWarning('', $msg);
         return $return;
     } elseif (!$billingaddresses->phone) {
         $return = 1;
         $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_PHONE');
         JError::raiseWarning('', $msg);
         return $return;
     }
     if ($billingaddresses->is_company == 1) {
         $extrafield_name = $extra_field->chk_extrafieldValidation(8, $billingaddresses->users_info_id);
         if (!empty($extrafield_name)) {
             $return = 1;
             $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
             JError::raiseWarning('', $msg);
             return $return;
         }
     } else {
         $extrafield_name = $extra_field->chk_extrafieldValidation(7, $billingaddresses->users_info_id);
         if (!empty($extrafield_name)) {
             $return = 1;
             $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
             JError::raiseWarning('', $msg);
             return $return;
         }
     }
     if (SHIPPING_METHOD_ENABLE && $users_info_id != $billingaddresses->users_info_id) {
         if ($billingaddresses->is_company == 1) {
             $extrafield_name = $extra_field->chk_extrafieldValidation(15, $users_info_id);
             if (!empty($extrafield_name)) {
                 $return = 2;
                 $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
                 JError::raiseWarning('', $msg);
                 return $return;
             }
         } else {
             $extrafield_name = $extra_field->chk_extrafieldValidation(14, $users_info_id);
             if (!empty($extrafield_name)) {
                 $return = 2;
                 $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED');
                 JError::raiseWarning('', $msg);
                 return $return;
             }
         }
     }
     return $return;
 }