Inheritance: extends AppModel
Exemplo n.º 1
0
 public function __construct($pesel)
 {
     $gender = new Gender($pesel);
     $gender->printOut();
     $birth = new Birth($pesel);
     $birth->printOut();
 }
 public function profile($id)
 {
     $user = User::with('gender', 'course', 'userType')->where('StudentID', $id)->first();
     $courses = Course::all()->lists('CourseAbbr', 'CourseID');
     $genders = Gender::all()->lists('Gender', 'GenderID');
     return View::make('validated.profile.edit', compact('user', 'courses', 'genders'));
 }
Exemplo n.º 3
0
 public function indexAction()
 {
     $db = $this->di->get('db');
     try {
         var_dump("Start!!");
         $db->begin();
         var_dump('First transaction is opened. Is under transaction: ' . (int) $db->isUnderTransaction());
         var_dump('First transaction is opened. Transaction level is ' . $db->getTransactionLevel());
         $gender = \Gender::findFirst(1);
         // Create user object and set gender relation
         $user = new User();
         $user->setName('Roc');
         $user->gender = $gender;
         // store user, but error occurs
         $user->save();
         $db->commit();
         var_dump("Commit!!!");
         var_dump('First transaction is commited. Is under transaction: ' . (int) $db->isUnderTransaction());
         var_dump('First transaction is commited. Transaction level is ' . $db->getTransactionLevel());
     } catch (\Exception $e) {
         var_dump('Catch: ' . $e->getMessage());
         $db->rollback();
         var_dump('First transaction is rollbacked. Is under transaction: ' . (int) $db->isUnderTransaction());
         var_dump('First transaction is rollbacked. Transaction level is ' . $db->getTransactionLevel());
     }
     /*
      * The problem is here.
      * Now, when the data are fetched via \Phalcon\MVC\Model, exception 'SQLSTATE[25P02]: In failed sql 
      * transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block' occurs
      * 
      * If you can use raw sql below, it's correct
      */
     try {
         $db->begin();
         var_dump('Second transaction is opened. Is under transaction: ' . (int) $db->isUnderTransaction());
         var_dump('Second transaction is opened. Transaction level is ' . $db->getTransactionLevel());
         $users = \User::find();
         var_dump($users);
         $db->commit();
     } catch (\Exception $e) {
         var_dump('Catch: ' . $e->getMessage());
         $db->rollback();
         var_dump('Second transaction is rollbacked. Is under transaction: ' . (int) $db->isUnderTransaction());
         var_dump('Second transaction is rollbacked. Transaction level is ' . $db->getTransactionLevel());
     }
     //		$sql = 'select * from users;';
     //		$result = $db->query($sql);
     //		$result->setFetchMode(\Phalcon\Db::FETCH_ASSOC);
     //		$result = $result->fetchAll($result);
     //		var_dump($result);
     var_dump("Done!!!");
     die;
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if ($this->customer->birthday) {
         $birthday = explode('-', $this->customer->birthday);
     } else {
         $birthday = array('-', '-', '-');
     }
     /* Generate years, months and days */
     $this->context->smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders()));
     if (Module::isInstalled('blocknewsletter')) {
         $this->context->smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
     }
     // start of implementation of the module code - taxamo
     // Get selected country
     if (Tools::isSubmit('taxamoisocountryresidence') && !is_null(Tools::getValue('taxamoisocountryresidence'))) {
         $selected_country = Tools::getValue('taxamoisocountryresidence');
     } else {
         $selected_country = Taxamoeuvat::getCountryByCustomer($this->customer->id);
     }
     // Generate countries list
     if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
         $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
     } else {
         $countries = Country::getCountries($this->context->language->id, true);
     }
     /* todo use helper */
     $list = '<option value="">-</option>';
     foreach ($countries as $country) {
         $selected = $country['iso_code'] == $selected_country ? 'selected="selected"' : '';
         $list .= '<option value="' . $country['iso_code'] . '" ' . $selected . '>' . htmlentities($country['name'], ENT_COMPAT, 'UTF-8') . '</option>';
     }
     // Get selected cc prefix
     if (Tools::isSubmit('taxamoccprefix') && !is_null(Tools::getValue('taxamoccprefix'))) {
         $taxamo_cc_prefix = Tools::getValue('taxamoccprefix');
     } else {
         $taxamo_cc_prefix = Taxamoeuvat::getPrefixByCustomer($this->customer->id);
     }
     if ($this->customer->id) {
         $this->context->smarty->assign(array('countries_list' => $list, 'taxamoisocountryresidence' => $selected_country, 'taxamoccprefix' => $taxamo_cc_prefix));
     }
     // end of code implementation module - taxamo
     $this->setTemplate(_PS_THEME_DIR_ . 'identity.tpl');
 }
 protected function renderCustomersList($group)
 {
     $genders = array(0 => '?');
     $genders_icon = array('default' => 'unknown.gif');
     foreach (Gender::getGenders() as $gender) {
         $genders_icon[$gender->id] = '../genders/' . (int) $gender->id . '.jpg';
         $genders[$gender->id] = $gender->name;
     }
     $customer_fields_display = array('id_customer' => array('title' => $this->l('ID'), 'width' => 15, 'align' => 'center'), 'id_gender' => array('title' => $this->l('Titles'), 'align' => 'center', 'width' => 50, 'icon' => $genders_icon, 'list' => $genders), 'firstname' => array('title' => $this->l('Name'), 'align' => 'center'), 'lastname' => array('title' => $this->l('Name'), 'align' => 'center'), 'email' => array('title' => $this->l('E-mail address'), 'width' => 150, 'align' => 'center'), 'birthday' => array('title' => $this->l('Birth date'), 'width' => 150, 'align' => 'right', 'type' => 'date'), 'date_add' => array('title' => $this->l('Register date'), 'width' => 150, 'align' => 'right', 'type' => 'date'), 'orders' => array('title' => $this->l('Orders'), 'align' => 'center'), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'width' => 20, 'active' => 'status', 'type' => 'bool'));
     $customer_list = $group->getCustomers(false);
     $helper = new HelperList();
     $helper->currentIndex = Context::getContext()->link->getAdminLink('AdminCustomers', false);
     $helper->token = Tools::getAdminTokenLite('AdminCustomers');
     $helper->shopLinkType = '';
     $helper->table = 'customer';
     $helper->identifier = 'id_customer';
     $helper->actions = array('edit', 'view');
     $helper->show_toolbar = false;
     return $helper->generateList($customer_list, $customer_fields_display);
 }
Exemplo n.º 6
0
 /**
  * Get $num names
  * @param $num
  * @param $additionalColumns
  * @return array
  * @throws \Exception
  */
 public function get($num, $additionalColumns = [])
 {
     $out = [];
     // check that all columns are allowed
     foreach ($additionalColumns as $column) {
         if (!in_array($column, $this->allowedColumns)) {
             throw new \Exception('column ' . $column . ' not allowed');
         }
     }
     for ($i = 0; $i < $num; $i++) {
         $item = [];
         $item['gender'] = Gender::getRandom();
         $item['first'] = $item['gender'] == Gender::GENDER_MALE ? $this->maleNames->getRandom() : $this->femaleNames->getRandom();
         $item['last'] = $this->lastNames->getRandom();
         $item['full'] = $item['first'] . ' ' . $item['last'];
         foreach ($additionalColumns as $column) {
             $item[$column] = $this->{$column}();
         }
         $out[] = $item;
     }
     return $out;
 }
Exemplo n.º 7
0
 public function getFormat()
 {
     $format = [];
     $format['id_customer'] = (new FormField())->setName('id_customer')->setType('hidden');
     $genderField = (new FormField())->setName('id_gender')->setType('radio-buttons')->setLabel($this->translator->trans('Social title', [], 'Shop.Forms.Labels'));
     foreach (Gender::getGenders($this->language->id) as $gender) {
         $genderField->addAvailableValue($gender->id, $gender->name);
     }
     $format[$genderField->getName()] = $genderField;
     $format['firstname'] = (new FormField())->setName('firstname')->setLabel($this->translator->trans('First name', [], 'Shop.Forms.Labels'))->setRequired(true);
     $format['lastname'] = (new FormField())->setName('lastname')->setLabel($this->translator->trans('Last name', [], 'Shop.Forms.Labels'))->setRequired(true);
     if (Configuration::get('PS_B2B_ENABLE')) {
         $format['company'] = (new FormField())->setName('company')->setType('text')->setLabel($this->translator->trans('Company', [], 'Shop.Forms.Labels'));
         $format['siret'] = (new FormField())->setName('siret')->setType('text')->setLabel($this->translator->trans('Identification number', [], 'Shop.Forms.Labels'));
     }
     $format['email'] = (new FormField())->setName('email')->setType('email')->setLabel($this->translator->trans('Email', [], 'Shop.Forms.Labels'))->setRequired(true);
     if ($this->ask_for_password) {
         $format['password'] = (new FormField())->setName('password')->setType('password')->setLabel($this->translator->trans('Password', [], 'Shop.Forms.Labels'))->setRequired($this->password_is_required);
     }
     if ($this->ask_for_new_password) {
         $format['new_password'] = (new FormField())->setName('new_password')->setType('password')->setLabel($this->translator->trans('New password', [], 'Shop.Forms.Labels'));
     }
     if ($this->ask_for_birthdate) {
         $format['birthday'] = (new FormField())->setName('birthday')->setType('text')->setLabel($this->translator->trans('Birthdate', [], 'Shop.Forms.Labels'))->addAvailableValue('placeholder', Tools::getDateFormat())->addAvailableValue('comment', $this->translator->trans('(E.g.: %date_format%)', array('%date_format%' => Tools::formatDateStr('31 May 1970')), 'Shop.Forms.Help'));
     }
     if ($this->ask_for_partner_optin) {
         $format['optin'] = (new FormField())->setName('optin')->setType('checkbox')->setLabel($this->translator->trans('Receive offers from our partners', [], 'Shop.Theme.CustomerAccount'));
     }
     $additionalCustomerFormFields = Hook::exec('additionalCustomerFormFields', array(), null, true);
     if (!is_array($additionalCustomerFormFields)) {
         $additionalCustomerFormFields = array();
     }
     $format = array_merge($format, $additionalCustomerFormFields);
     // TODO: TVA etc.?
     return $this->addConstraints($format);
 }
Exemplo n.º 8
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     /* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
     if (empty($this->context->cart->id_carrier)) {
         $checked = $this->context->cart->simulateCarrierSelectedOutput();
         $checked = (int) Cart::desintifier($checked);
         $this->context->cart->id_carrier = $checked;
         $this->context->cart->update();
         CartRule::autoRemoveFromCart($this->context);
         CartRule::autoAddToCart($this->context);
     }
     // SHOPPING CART
     $this->_assignSummaryInformations();
     // WRAPPING AND TOS
     $this->_assignWrappingAndTOS();
     $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
         $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
     } else {
         $countries = Country::getCountries($this->context->language->id, true);
     }
     // If a rule offer free-shipping, force hidding shipping prices
     $free_shipping = false;
     foreach ($this->context->cart->getCartRules() as $rule) {
         if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
             $free_shipping = true;
             break;
         }
     }
     $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => (bool) (isset($_GET['isPaymentStep']) && $_GET['isPaymentStep']), 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
     $years = Tools::dateYears();
     $months = Tools::dateMonths();
     $days = Tools::dateDays();
     $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days));
     /* Load guest informations */
     if ($this->isLogged && $this->context->cookie->is_guest) {
         $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
     }
     // ADDRESS
     if ($this->isLogged) {
         $this->_assignAddress();
     }
     // CARRIER
     $this->_assignCarrier();
     // PAYMENT
     $this->_assignPayment();
     Tools::safePostVars();
     $blocknewsletter = Module::getInstanceByName('blocknewsletter');
     $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active));
     $this->_processAddressFormat();
     $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl');
 }
Exemplo n.º 9
0
echo $form->textField($model, 'last_name');
?>
</td>
		<td><?php 
echo $form->error($model, 'last_name');
?>
</td>
	</div></tr>
        
        <tr><div class="row">
                    <td><?php 
echo $form->labelEx($model, 'gender');
?>
</td>
                    <td><?php 
echo $form->dropdownList($model, 'gender', CHtml::listData(Gender::model()->findAll(), 'id', 'gender'), array('prompt' => 'Select Gender'));
?>
</td>
                    <td><?php 
echo $form->error($model, 'gender');
?>
</td>
       </div></tr>
        
        <tr><div class="row">
		<td><?php 
echo $form->labelEx($model, 'dob');
?>
</td>
		<td> <?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'dob', 'options' => array('showAnim' => 'fold', 'dateFormat' => 'yy-mm-dd', 'minDate' => ''), 'htmlOptions' => array()));
Exemplo n.º 10
0
 public function retrieveEvents()
 {
     $url = NEFUB_ROOT . '/../pages/default.asp?subject_id=20';
     $postData = array('category_id' => 205);
     $html = $this->getNefubContents($url, 2, $postData);
     if (!$html) {
         $this->retrieveLog->successfully = 0;
     } else {
         $this->retrieveLog->successfully = 1;
     }
     $this->retrieveLog->finish_time = date('Y-m-d H:i:s');
     $this->retrieveLog->total_time = $this->retrieveLog->getDuration();
     $this->retrieveLog->finished = 1;
     $this->retrieveLog->save();
     $pattern = '|<td width=\\"100\\" valign=top class=\\"kalender_subtitle\\">(.*){4,16}<td valign=top class=\\"kalender_subtitle\\">([^<]{4,})<br|U';
     $result = array();
     preg_match_all($pattern, $html, $result, PREG_SET_ORDER);
     $aEvents = array();
     foreach ($result as $event) {
         /*
         	[35]: Array
         	[35][0]: <td width="100" valign=top class="kalender_subtitle">za. 12.04.2014</td><td valign=top class="kalender_subtitle"> NeFUB Competitie ronde 15 <br
         	[35][1]: za. 12.04.2014</td>
         	[35][2]: NeFUB Competitie ronde 15
         */
         $nefubName = utf8_encode(trim($event[2]));
         $lowerName = strtolower($nefubName);
         $oGenre = null;
         $oGender = null;
         $oGender2 = null;
         if (strpos($lowerName, 'jeugd') !== false) {
             $oGenre = Genre::getByNefubName(GENRE_JEUGD_NEFUB_NAME);
             $oGender = Gender::getByNefubName(GENDER_MIXED_NEFUB_NAME);
         } elseif (strpos($lowerName, 'mixed') !== false) {
             $oGenre = Genre::getByNefubName(GENRE_COMPETITIE_NEFUB_NAME);
             $oGender = Gender::getByNefubName(GENDER_MIXED_NEFUB_NAME);
         } else {
             if (strpos($lowerName, 'heren') !== false) {
                 $oGender = Gender::getByNefubName(GENDER_HEREN_NEFUB_NAME);
             } elseif (strpos($lowerName, 'dames') !== false) {
                 $oGender = Gender::getByNefubName(GENDER_DAMES_NEFUB_NAME);
             } else {
                 $oGender = Gender::getByNefubName(GENDER_HEREN_NEFUB_NAME);
                 $oGender2 = Gender::getByNefubName(GENDER_DAMES_NEFUB_NAME);
             }
             if (strpos($lowerName, 'cup') !== false || strpos($lowerName, 'beker') !== false) {
                 $oGenre = Genre::getByNefubName(GENRE_BEKER_NEFUB_NAME);
             } else {
                 $oGenre = Genre::getByNefubName(GENRE_COMPETITIE_NEFUB_NAME);
             }
         }
         $date = str_replace('</td>', '', $event[1]);
         $date = array_pop(explode(' ', $date));
         $dates = explode('-', $date);
         if (count($dates) > 1) {
             if (count($dates) == 2) {
                 $lastDate = array_pop($dates);
                 list($lastDay, $month, $year) = explode('.', trim($lastDate));
                 $firstDay = $dates[0];
                 $firstDate = $year . '-' . $month . '-' . $firstDay;
                 $oEvent = self::convertEvent($nefubName, $firstDate, $oGenre, $oGender);
                 $eventIds[] = $oEvent->getId();
                 if ($oGender2) {
                     $oEvent = self::convertEvent($nefubName, $firstDate, $oGenre, $oGender2);
                     $eventIds[] = $oEvent->getId();
                 }
                 $lastDate = $year . '-' . $month . '-' . $lastDay;
                 $oEvent = self::convertEvent($nefubName, $lastDate, $oGenre, $oGender);
                 $eventIds[] = $oEvent->getId();
                 if ($oGender2) {
                     $oEvent = self::convertEvent($nefubName, $firstDate, $oGenre, $oGender2);
                     $eventIds[] = $oEvent->getId();
                 }
                 self::put("Event " . $nefubName . " toegevoegd");
             } else {
                 self::put("Event " . $nefubName . " niet toegevoegd, ongeldige data:");
                 self::put($date);
             }
         } else {
             list($day, $month, $year) = explode('.', $date);
             $formattedDate = $year . '-' . $month . '-' . $day;
             $oEvent = self::convertEvent($nefubName, $formattedDate, $oGenre, $oGender);
             $eventIds[] = $oEvent->getId();
             if ($oGender2) {
                 $oEvent = self::convertEvent($nefubName, $formattedDate, $oGenre, $oGender2);
                 $eventIds[] = $oEvent->getId();
             }
             self::put("Event " . $nefubName . " toegevoegd");
         }
         if (count($eventIds)) {
             $query = 'DELETE FROM Event WHERE id NOT IN (' . implode(', ', $eventIds) . ') AND season_nefub_id = ' . Season::getInstance()->nefub_id;
             Database::query($query);
         } else {
             Database::delete_rows('Event', array('season_nefub_id' => Season::getInstance()->nefub_id));
         }
     }
 }
Exemplo n.º 11
0
 public function FirstName()
 {
     if (StakeLeader::IsLoggedIn()) {
         return $this->FirstName;
     }
     $formal = false;
     $callings = $this->Callings();
     $merited = array("Bishop", "Bishopric 1st Counselor", "Bishopric 2nd Counselor", "High Counselor");
     // First check for calling
     foreach ($callings as $c) {
         if ($c->Name == "Bishop") {
             return "Bishop";
         }
         // Bishop gets own title
         if (in_array($c->Name, $merited)) {
             $formal = true;
             break;
         }
     }
     // Now check age if not already decided
     if (!$formal) {
         $secondsPerYear = 31557600;
         $formal = floor(abs(strtotime(now()) - strtotime($this->Birthday)) / $secondsPerYear) > 30;
     }
     return $formal ? Gender::RenderLDS($this->Gender) : $this->FirstName;
 }
Exemplo n.º 12
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if ($this->customer->birthday) {
         $birthday = explode('-', $this->customer->birthday);
     } else {
         $birthday = array('-', '-', '-');
     }
     /* Generate years, months and days */
     $this->context->smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders()));
     $this->context->smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
     $this->setTemplate(_PS_THEME_DIR_ . 'identity.tpl');
 }
Exemplo n.º 13
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->context->smarty->assign('genders', Gender::getGenders());
     $this->assignDate();
     $this->assignCountries();
     $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active;
     $this->context->smarty->assign('newsletter', $newsletter);
     $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN'));
     $back = Tools::getValue('back');
     $key = Tools::safeOutput(Tools::getValue('key'));
     if (!empty($key)) {
         $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key;
     }
     if ($back == Tools::secureReferrer(Tools::getValue('back'))) {
         $this->context->smarty->assign('back', html_entity_decode($back));
     } else {
         $this->context->smarty->assign('back', Tools::safeOutput($back));
     }
     if (Tools::getValue('display_guest_checkout')) {
         if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
             $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
         } else {
             $countries = Country::getCountries($this->context->language->id, true);
         }
         $this->context->smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'sl_country' => (int) $this->id_country, 'countries' => $countries));
     }
     if (Tools::getValue('create_account')) {
         $this->context->smarty->assign('email_create', 1);
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
     $this->assignAddressFormat();
     // Call a hook to display more information on form
     $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
     // Just set $this->template value here in case it's used by Ajax
     $this->setTemplate(_PS_THEME_DIR_ . 'authentication.tpl');
     if ($this->ajax) {
         // Call a hook to display more information on form
         $this->context->smarty->assign(array('PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'genders' => Gender::getGenders()));
         $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'page' => $this->context->smarty->fetch($this->template), 'token' => Tools::getToken(false));
         $this->ajaxDie(Tools::jsonEncode($return));
     }
 }
Exemplo n.º 14
0
        }
        // Consolidate leadership (e.g. leader1, leader3, but no leader2 = messy)
        // This also persists (saves) the object in the DB.
        $currentGroup->ConsolidateLeaders();
    }
    // Assign to new group
    $mem->FheGroup = $groupID;
    // Build the response
    $response = "Success";
    if (!$groupID) {
        $response = "Removed {$mem->FirstName} from " . Gender::PossessivePronoun($mem->Gender) . " group.";
    } else {
        $response = "Assigned {$mem->FirstName} to group {$mem->FheGroup()->GroupName}.";
    }
    if ($removedLeader) {
        $response .= " This member is no longer a leader of " . Gender::PossessivePronoun($mem->Gender) . " old group.";
    }
    if ($mem->Save()) {
        Response::Send(200, $response);
    } else {
        Response::Send(500, "Something went wrong; could not save member's new assignment.");
    }
} elseif ($action == "del") {
    $id = DB::Safe($_GET['id']);
    // Remove all members from this group which is about to be deleted
    $r = DB::Run("UPDATE Members SET FheGroup=0 WHERE FheGroup={$id}");
    if (!$r) {
        Response::Send(500, "Could not remove members from FHE group: " . mysql_error());
    }
    // Delete the group
    $r = DB::Run("DELETE FROM FheGroups WHERE id={$id} LIMIT 1");
Exemplo n.º 15
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if ($this->customer->birthday) {
         $birthday = explode('-', $this->customer->birthday);
     } else {
         $birthday = array('-', '-', '-');
     }
     /* Generate years, months and days */
     $this->context->smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders()));
     // Call a hook to display more information
     $this->context->smarty->assign(array('HOOK_CUSTOMER_IDENTITY_FORM' => Hook::exec('displayCustomerIdentityForm')));
     $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active;
     $this->context->smarty->assign('newsletter', $newsletter);
     $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN'));
     $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
     $this->setTemplate(_PS_THEME_DIR_ . 'identity.tpl');
 }
Exemplo n.º 16
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->context->smarty->assign('genders', Gender::getGenders());
     $this->assignDate();
     $this->assignCountries();
     $active_module_newsletter = false;
     if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) {
         $active_module_newsletter = $module_newsletter->active;
     }
     $this->context->smarty->assign('newsletter', (int) $active_module_newsletter);
     $back = Tools::getValue('back');
     $key = Tools::safeOutput(Tools::getValue('key'));
     if (!empty($key)) {
         $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key;
     }
     if (!empty($back)) {
         $this->context->smarty->assign('back', Tools::safeOutput($back));
     }
     if (Tools::getValue('display_guest_checkout')) {
         if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
             $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
         } else {
             $countries = Country::getCountries($this->context->language->id, true);
         }
         $this->context->smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'sl_country' => (int) Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')), 'countries' => $countries));
     }
     if (Tools::getValue('create_account')) {
         $this->context->smarty->assign('email_create', 1);
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     $this->assignAddressFormat();
     // Call a hook to display more information on form
     $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
     if ($this->ajax) {
         // Call a hook to display more information on form
         $this->context->smarty->assign(array('PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'genders' => Gender::getGenders()));
         $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'page' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'authentication.tpl'), 'token' => Tools::getToken(false));
         die(Tools::jsonEncode($return));
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'authentication.tpl');
 }
    public function renderView()
    {
        /** @var Customer $customer */
        if (!($customer = $this->loadObject())) {
            return;
        }
        $this->context->customer = $customer;
        $gender = new Gender($customer->id_gender, $this->context->language->id);
        $gender_image = $gender->getImage();
        $customer_stats = $customer->getStats();
        $sql = 'SELECT SUM(total_paid_real) FROM ' . _DB_PREFIX_ . 'orders WHERE id_customer = %d AND valid = 1';
        if ($total_customer = Db::getInstance()->getValue(sprintf($sql, $customer->id))) {
            $sql = 'SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM ' . _DB_PREFIX_ . 'orders WHERE valid = 1 AND id_customer != ' . (int) $customer->id . ' GROUP BY id_customer HAVING SUM(total_paid_real) > %d';
            Db::getInstance()->getValue(sprintf($sql, (int) $total_customer));
            $count_better_customers = (int) Db::getInstance()->getValue('SELECT FOUND_ROWS()') + 1;
        } else {
            $count_better_customers = '-';
        }
        $orders = Order::getCustomerOrders($customer->id, true);
        $total_orders = count($orders);
        for ($i = 0; $i < $total_orders; $i++) {
            $orders[$i]['total_paid_real_not_formated'] = $orders[$i]['total_paid_real'];
            $orders[$i]['total_paid_real'] = Tools::displayPrice($orders[$i]['total_paid_real'], new Currency((int) $orders[$i]['id_currency']));
        }
        $messages = CustomerThread::getCustomerMessages((int) $customer->id);
        $total_messages = count($messages);
        for ($i = 0; $i < $total_messages; $i++) {
            $messages[$i]['message'] = substr(strip_tags(html_entity_decode($messages[$i]['message'], ENT_NOQUOTES, 'UTF-8')), 0, 75);
            $messages[$i]['date_add'] = Tools::displayDate($messages[$i]['date_add'], null, true);
            if (isset(self::$meaning_status[$messages[$i]['status']])) {
                $messages[$i]['status'] = self::$meaning_status[$messages[$i]['status']];
            }
        }
        $groups = $customer->getGroups();
        $total_groups = count($groups);
        for ($i = 0; $i < $total_groups; $i++) {
            $group = new Group($groups[$i]);
            $groups[$i] = array();
            $groups[$i]['id_group'] = $group->id;
            $groups[$i]['name'] = $group->name[$this->default_form_language];
        }
        $total_ok = 0;
        $orders_ok = array();
        $orders_ko = array();
        foreach ($orders as $order) {
            if (!isset($order['order_state'])) {
                $order['order_state'] = $this->l('There is no status defined for this order.');
            }
            if ($order['valid']) {
                $orders_ok[] = $order;
                $total_ok += $order['total_paid_real_not_formated'];
            } else {
                $orders_ko[] = $order;
            }
        }
        $products = $customer->getBoughtProducts();
        $carts = Cart::getCustomerCarts($customer->id);
        $total_carts = count($carts);
        for ($i = 0; $i < $total_carts; $i++) {
            $cart = new Cart((int) $carts[$i]['id_cart']);
            $this->context->cart = $cart;
            $summary = $cart->getSummaryDetails();
            $currency = new Currency((int) $carts[$i]['id_currency']);
            $carrier = new Carrier((int) $carts[$i]['id_carrier']);
            $carts[$i]['id_cart'] = sprintf('%06d', $carts[$i]['id_cart']);
            $carts[$i]['date_add'] = Tools::displayDate($carts[$i]['date_add'], null, true);
            $carts[$i]['total_price'] = Tools::displayPrice($summary['total_price'], $currency);
            $carts[$i]['name'] = $carrier->name;
        }
        $sql = 'SELECT DISTINCT cp.id_product, c.id_cart, c.id_shop, cp.id_shop AS cp_id_shop
				FROM ' . _DB_PREFIX_ . 'cart_product cp
				JOIN ' . _DB_PREFIX_ . 'cart c ON (c.id_cart = cp.id_cart)
				JOIN ' . _DB_PREFIX_ . 'product p ON (cp.id_product = p.id_product)
				WHERE c.id_customer = ' . (int) $customer->id . '
					AND NOT EXISTS (
							SELECT 1
							FROM ' . _DB_PREFIX_ . 'orders o
							JOIN ' . _DB_PREFIX_ . 'order_detail od ON (o.id_order = od.id_order)
							WHERE product_id = cp.id_product AND o.valid = 1 AND o.id_customer = ' . (int) $customer->id . '
						)';
        $interested = Db::getInstance()->executeS($sql);
        $total_interested = count($interested);
        for ($i = 0; $i < $total_interested; $i++) {
            $product = new Product($interested[$i]['id_product'], false, $this->default_form_language, $interested[$i]['id_shop']);
            if (!Validate::isLoadedObject($product)) {
                continue;
            }
            $interested[$i]['url'] = $this->context->link->getProductLink($product->id, $product->link_rewrite, Category::getLinkRewrite($product->id_category_default, $this->default_form_language), null, null, $interested[$i]['cp_id_shop']);
            $interested[$i]['id'] = (int) $product->id;
            $interested[$i]['name'] = Tools::htmlentitiesUTF8($product->name);
        }
        $emails = $customer->getLastEmails();
        $connections = $customer->getLastConnections();
        if (!is_array($connections)) {
            $connections = array();
        }
        $total_connections = count($connections);
        for ($i = 0; $i < $total_connections; $i++) {
            $connections[$i]['http_referer'] = $connections[$i]['http_referer'] ? preg_replace('/^www./', '', parse_url($connections[$i]['http_referer'], PHP_URL_HOST)) : $this->l('Direct link');
        }
        $referrers = Referrer::getReferrers($customer->id);
        $total_referrers = count($referrers);
        for ($i = 0; $i < $total_referrers; $i++) {
            $referrers[$i]['date_add'] = Tools::displayDate($referrers[$i]['date_add'], null, true);
        }
        $customerLanguage = new Language($customer->id_lang);
        $shop = new Shop($customer->id_shop);
        $this->tpl_view_vars = array('customer' => $customer, 'gender' => $gender, 'gender_image' => $gender_image, 'registration_date' => Tools::displayDate($customer->date_add, null, true), 'customer_stats' => $customer_stats, 'last_visit' => Tools::displayDate($customer_stats['last_visit'], null, true), 'count_better_customers' => $count_better_customers, 'shop_is_feature_active' => Shop::isFeatureActive(), 'name_shop' => $shop->name, 'customer_birthday' => Tools::displayDate($customer->birthday), 'last_update' => Tools::displayDate($customer->date_upd, null, true), 'customer_exists' => Customer::customerExists($customer->email), 'id_lang' => $customer->id_lang, 'customerLanguage' => $customerLanguage, 'customer_note' => Tools::htmlentitiesUTF8($customer->note), 'messages' => $messages, 'groups' => $groups, 'orders' => $orders, 'orders_ok' => $orders_ok, 'orders_ko' => $orders_ko, 'total_ok' => Tools::displayPrice($total_ok, $this->context->currency->id), 'products' => $products, 'addresses' => $customer->getAddresses($this->default_form_language), 'discounts' => CartRule::getCustomerCartRules($this->default_form_language, $customer->id, false, false), 'carts' => $carts, 'interested' => $interested, 'emails' => $emails, 'connections' => $connections, 'referrers' => $referrers, 'show_toolbar' => true);
        return parent::renderView();
    }
Exemplo n.º 18
0
 public function initContent()
 {
     $internal_referrer = isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], Dispatcher::getInstance()->createUrl('order-opc', $this->context->cookie->id_lang));
     $upsell = @Module::getInstanceByName('upsell');
     if ($upsell && $upsell->active && !(Tools::getValue('skip_offers') == 1 || $internal_referrer)) {
         ParentOrderController::initContent();
         // We need this to display the page properly (parent of overriden controller)
         $upsell->getUpsells();
         $this->template = $upsell->setTemplate('upsell-products.tpl');
     } else {
         if (!$this->isOpcModuleActive()) {
             return parent::initContent();
         }
         $this->origInitContent();
         $this->_assignSummaryInformations();
         $this->_assignWrappingAndTOS();
         $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
             $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
         } else {
             $countries = Country::getCountries($this->context->language->id, true);
         }
         $free_shipping = false;
         foreach ($this->context->cart->getCartRules() as $rule) {
             if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
                 $free_shipping = true;
                 break;
             }
         }
         $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isLogged' => $this->isLogged, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier before', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service before', false), 'isPaymentStep' => (bool) (Tools::getIsset('isPaymentStep') && Tools::getValue('isPaymentStep')), 'genders' => Gender::getGenders()));
         $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
         $years = Tools::dateYears();
         $months = Tools::dateMonths();
         $days = Tools::dateDays();
         $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days));
         if ($this->isLogged) {
             $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
         }
         if ($this->context->cart->id_address_delivery > 0) {
             $def_address = new Address($this->context->cart->id_address_delivery);
             $def_country = $def_address->id_country;
             $def_state = $def_address->id_state;
         } else {
             $def_country = 0;
             $def_state = 0;
         }
         if ($this->context->cart->id_address_invoice > 0) {
             $def_address_invoice = new Address($this->context->cart->id_address_invoice);
             $def_country_invoice = $def_address_invoice->id_country;
             $def_state_invoice = $def_address_invoice->id_state;
         } else {
             $def_country_invoice = 0;
             $def_state_invoice = 0;
         }
         if ($this->context->cart->id_address_delivery > 0 && $this->context->cart->id_address_invoice > 0 && $this->context->cart->id_address_delivery != $this->context->cart->id_address_invoice) {
             $def_different_billing = 1;
         } else {
             $def_different_billing = 0;
         }
         $this->context->smarty->assign('def_different_billing', $def_different_billing);
         $this->context->smarty->assign('def_country', $def_country);
         $this->context->smarty->assign('def_state', $def_state);
         $this->context->smarty->assign('def_country_invoice', $def_country_invoice);
         $this->context->smarty->assign('def_state_invoice', $def_state_invoice);
         if ($this->isLogged) {
             $this->_assignAddress();
         }
         // ADDRESS
         $this->_assignCarrier();
         $this->_assignPayment();
         Tools::safePostVars();
         if (!$this->context->cart->isMultiAddressDelivery()) {
             $this->context->cart->setNoMultishipping();
         }
         // As the cart is no multishipping, set each delivery address lines with the main delivery address
         $summary = $this->context->cart->getSummaryDetails(null, true);
         // to force refresh on product.id_address_delivery
         $this->_assignSummaryInformations();
         $blocknewsletter = Module::getInstanceByName('blocknewsletter');
         $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active));
         $this->context->smarty->assign('opc_templates_path', $this->opc_templates_path);
         $this->context->smarty->assign('twoStepCheckout', false);
         // TODO: hardcoded value!
         $online_country = new Country($this->opc_config['online_country_id']);
         if ($online_country->active) {
             $this->context->smarty->assign('onlineCountryActive', true);
         }
         if (Tools::isSubmit('cart-only')) {
             $this->context->smarty->assign('onlyCartSummary', '1');
             $this->context->smarty->assign('order_process_type', Configuration::get('PS_ORDER_PROCESS_TYPE'));
             $this->setTemplate('shopping-cart.tpl');
         } else {
             $this->setTemplate('order-opc.tpl');
         }
     }
 }
Exemplo n.º 19
0
 /**
  *
  * @param string nefub name
  * @return NefubType
  */
 public static function getByNefubName($nefubName, $date, Gender $oGender)
 {
     return self::getSingle(array('nefub_name' => $nefubName, 'date' => $date, 'gender_id' => $oGender->getId()));
 }
echo $form->textArea($element, 'address', array(), false, array('rows' => 4), array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->textField($element, 'postcode', array(), array(), array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->textField($element, 'email', array(), array(), array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->textField($element, 'telephone', array(), array(), array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->datePicker($element, 'date_of_birth', array(), array(), array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->dropDownList($element, 'gender_id', CHtml::listData(Gender::model()->findAll(), 'id', 'name'), array('empty' => '- Please Select -'), false, array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->dropDownList($element, 'ethnic_group_id', CHtml::listData(EthnicGroup::model()->findAll(), 'id', 'name'), array('empty' => '- Please Select -'), false, array('label' => 4, 'field' => 8));
?>
    </div>
    <div class="large-6 column">
        <?php 
echo $form->textField($element, 'nhs_number', array(), array(), array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->textField($element, 'gp_name', array(), array(), array('label' => 4, 'field' => 8));
?>
        <?php 
echo $form->textArea($element, 'gp_address', array(), false, array('rows' => 4), array('label' => 4, 'field' => 8));
?>
Exemplo n.º 21
0
 public function displayContent()
 {
     parent::displayContent();
     $customer = new Customer((int) self::$cart->id_customer);
     $address_invoice = new Address((int) self::$cart->id_address_invoice);
     $country = new Country((int) $address_invoice->id_country);
     $currency = new Currency((int) self::$cart->id_currency);
     $countries = $this->klarna->getCountries();
     $type = Tools::getValue('type');
     if ($this->klarna->verifCountryAndCurrency($country, $currency) && ($type == 'invoice' || $type == 'account' || $type == 'special')) {
         $pno = array('SE' => 'yymmdd-nnnn', 'FI' => 'ddmmyy-nnnn', 'DK' => 'ddmmyynnnn', 'NO' => 'ddmmyynnnn', 'DE' => 'ddmmyy', 'NE' => 'ddmmyynnnn');
         self::$smarty->assign('country', $country);
         self::$smarty->assign('pnoValue', $pno[$country->iso_code]);
         self::$smarty->assign('iso_code', strtolower($country->iso_code));
         $i = 1;
         while ($i <= 31) {
             if ($i < 10) {
                 $days[] = '0' . $i;
             } else {
                 $days[] = $i;
             }
             $i++;
         }
         $i = 1;
         while ($i <= 12) {
             if ($i < 10) {
                 $months[] = '0' . $i;
             } else {
                 $months[] = $i;
             }
             $i++;
         }
         $i = 2000;
         while ($i >= 1910) {
             $years[] = $i--;
         }
         $houseInfo = $this->getHouseInfo($address_invoice->address1);
         self::$smarty->assign(array('days' => $days, 'customer_day' => (int) substr($customer->birthday, 8, 2), 'months' => $months, 'customer_month' => (int) substr($customer->birthday, 5, 2), 'years' => $years, 'customer_year' => (int) substr($customer->birthday, 0, 4), 'street_number' => $houseInfo[1], 'house_ext' => $houseInfo[2]));
         if ($type == 'invoice') {
             $total = self::$cart->getOrderTotal() + (double) Product::getPriceStatic((int) Configuration::get('KLARNA_INV_FEE_ID_' . $countries[$country->iso_code]['name']));
         } else {
             $total = self::$cart->getOrderTotal();
         }
         self::$smarty->assign(array('total_fee' => $total, 'fee' => $type == 'invoice' ? (double) Product::getPriceStatic((int) Configuration::get('KLARNA_INV_FEE_ID_' . $countries[$country->iso_code]['name'])) : 0));
         if ($type == 'account') {
             self::$smarty->assign('accountPrice', $this->getMonthlyCoast(self::$cart, $countries, $country));
         }
         if ($customer->id_gender != 1 && $customer->id_gender != 2 && $customer->id_gender != 3 && ($country->iso_code == 'DE' || $country->iso_code == 'NL')) {
             self::$smarty->assign('gender', Gender::getGenders()->getResults());
         }
         self::$smarty->assign('linkTermsCond', $type == 'invoice' ? 'https://online.klarna.com/villkor' . ($country->iso_code != 'SE' ? '_' . strtolower($country->iso_code) : '') . '.yaws?eid=' . (int) Configuration::get('KLARNA_STORE_ID_' . $countries[$country->iso_code]['name']) . '&charge=' . round((double) Product::getPriceStatic((int) Configuration::get('KLARNA_INV_FEE_ID_' . $countries[$country->iso_code]['name'])), 2) : 'https://online.klarna.com/account_' . strtolower($country->iso_code) . '.yaws?eid=' . (int) Configuration::get('KLARNA_STORE_ID_' . $countries[$country->iso_code]['name']));
         self::$smarty->assign('payment_type', Tools::safeOutput($type));
         self::$smarty->display(_PS_MODULE_DIR_ . 'klarnaprestashop/tpl/form.tpl');
     }
 }
Exemplo n.º 22
0
                                   <?php 
$ape_pat_alumno = $action == 'EDIT' ? $data['ape_pat_alumno'] : '';
if ($action == 'EDIT' || $action == 'INSERT') {
    Forms::printInput('TEXT', 'ape_pat_alumno', $ape_pat_alumno, 'mini', array('REQUIRED' => $property["FORMS"]["VALIDATION_GENERIC"]["REQUIRED_VALUE"]));
} elseif ($action == 'PREVIEW') {
    echo $data['ape_pat_alumno'];
}
if ($action != 'PREVIEW') {
    ?>
 <span class="rojo">*</span><?php 
}
?>
                                  </td>
                                  <td>SEXO:</td>
                                  <td> <?php 
$genero = new Gender($db);
$catalogo1 = $genero->getListGender();
$itemsSelect = array();
foreach ($catalogo1 as $item) {
    $itemsSelect[$item['id']] = $item['name'];
}
$itemsSelect['0'] = 'SELECCIONE UNA OPCION';
$gender = '';
if ($action == 'EDIT' || $action == 'PREVIEW') {
    $gender = $data['GENDER'];
}
Forms::printInput('SELECT', 'GENDER', $gender, 'select_requerido', array(), $itemsSelect);
if ($action != 'PREVIEW') {
    ?>
 <span class="rojo">*</span><?php 
}
 protected function renderCustomersList($group)
 {
     $genders = array(0 => '?');
     $genders_icon = array('default' => 'unknown.gif');
     foreach (Gender::getGenders() as $gender) {
         $genders_icon[$gender->id] = '../genders/' . (int) $gender->id . '.jpg';
         $genders[$gender->id] = $gender->name;
     }
     $this->table = 'customer_group';
     $this->lang = false;
     $this->list_id = 'customer_group';
     $this->actions = array();
     $this->addRowAction('edit');
     $this->identifier = 'id_customer';
     $this->bulk_actions = false;
     $this->list_no_link = true;
     $this->explicitSelect = true;
     $this->fields_list = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'filter_key' => 'c!id_customer', 'class' => 'fixed-width-xs'), 'id_gender' => array('title' => $this->l('Social title'), 'icon' => $genders_icon, 'list' => $genders), 'firstname' => array('title' => $this->l('First name')), 'lastname' => array('title' => $this->l('Last name')), 'email' => array('title' => $this->l('Email address'), 'filter_key' => 'c!email', 'orderby' => true), 'birthday' => array('title' => $this->l('Birth date'), 'type' => 'date', 'class' => 'fixed-width-md', 'align' => 'center'), 'date_add' => array('title' => $this->l('Registration date'), 'type' => 'date', 'class' => 'fixed-width-md', 'align' => 'center'), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'class' => 'fixed-width-sm', 'active' => 'status', 'type' => 'bool', 'search' => false, 'orderby' => false, 'filter_key' => 'c!active'));
     $this->_select = 'c.*, a.id_group';
     $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (a.`id_customer` = c.`id_customer`)';
     $this->_where = 'AND a.`id_group` = ' . (int) $group->id . ' AND c.`deleted` != 1';
     self::$currentIndex = self::$currentIndex . '&viewgroup';
     $this->processFilter();
     return parent::renderList();
 }
Exemplo n.º 24
0
 public function actionViewProfile($userId)
 {
     $this->layout = "layout_profile";
     $user = UserProfile::model()->find('user_id=:userId', array(':userId' => $userId));
     $country = Country::model()->find('id=:cId', array(':cId' => $user->country_id));
     $gender = Gender::model()->find('id=:gId', array(':gId' => $user->gender));
     $userFriend = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => Yii::app()->user->userId, ':friendId' => $user->user_id, ':status' => 0));
     $userFriend2 = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => $user->user_id, ':friendId' => Yii::app()->user->userId, ':status' => 0));
     $isFriend = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => Yii::app()->user->userId, ':friendId' => $user->user_id, ':status' => 1));
     $isFriend2 = UserFriend::model()->find('user_id=:userId AND friend_id=:friendId AND status=:status', array(':userId' => $user->user_id, ':friendId' => Yii::app()->user->userId, ':status' => 1));
     //$posts = Post::model()->findAll(array('select' => '*','condition' => 'user_id=:userId','params' => array(':userId' => $userId),'order'=>'date DESC'));
     //$posts = PostTagging::model()->with('post')->findAll(array('select' => '*','distinct'=>true,'condition' => 't.user_id=:userId OR t.sender_id=:userId','params' => array(':userId' => $userId),'order'=>'post.date DESC'));
     $posts = PostTagging::model()->findAllBySql("SELECT DISTINCT( post_id ) AS post_id FROM post_tagging,posts WHERE post_tagging.user_id={$userId} OR post_tagging.sender_id={$userId} ORDER By post_tagging.id DESC");
     if (!empty($posts)) {
         foreach ($posts as $p) {
             $post[] = Post::model()->find(array('select' => '*', 'condition' => 'id=:postId', 'params' => array(':postId' => $p->post_id), 'order' => 'date DESC'));
         }
     } else {
         $post = Null;
     }
     $CheckuserFriend = UserFriend::model()->find('(user_id=:userId AND friend_id=:friendId) OR (user_id=:friendId AND friend_id=:userId) AND status=1', array(':userId' => Yii::app()->user->userId, ':friendId' => $userId));
     $this->render('viewprofile', array('posts' => $post, 'model' => $user, 'country' => $country, 'gender' => $gender, 'userFriend' => $userFriend, 'userFriend2' => $userFriend2, 'isFriend' => $isFriend, 'isFriend2' => $isFriend2, 'checkFriend' => $CheckuserFriend));
 }
Exemplo n.º 25
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->context->smarty->assign('genders', Gender::getGenders());
     $this->assignDate();
     $this->assignCountries();
     $this->context->smarty->assign('newsletter', 1);
     $back = Tools::getValue('back');
     $key = Tools::safeOutput(Tools::getValue('key'));
     if (!empty($key)) {
         $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key;
     }
     if ($back == Tools::secureReferrer(Tools::getValue('back'))) {
         $this->context->smarty->assign('back', html_entity_decode($back));
     } else {
         $this->context->smarty->assign('back', Tools::safeOutput($back));
     }
     if (Tools::getValue('display_guest_checkout')) {
         if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
             $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
         } else {
             $countries = Country::getCountries($this->context->language->id, true);
         }
         if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             // get all countries as language (xy) or language-country (wz-XY)
             $array = array();
             preg_match("#(?<=-)\\w\\w|\\w\\w(?!-)#", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
             if (!Validate::isLanguageIsoCode($array[0]) || !($sl_country = Country::getByIso($array[0]))) {
                 $sl_country = (int) Configuration::get('PS_COUNTRY_DEFAULT');
             }
         } else {
             $sl_country = (int) Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT'));
         }
         $this->context->smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'sl_country' => (int) $sl_country, 'countries' => $countries));
     }
     if (Tools::getValue('create_account')) {
         $this->context->smarty->assign('email_create', 1);
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     $this->assignAddressFormat();
     // Call a hook to display more information on form
     $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
     // Just set $this->template value here in case it's used by Ajax
     $this->setTemplate(_PS_THEME_DIR_ . 'authentication.tpl');
     if ($this->ajax) {
         // Call a hook to display more information on form
         $this->context->smarty->assign(array('PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'genders' => Gender::getGenders()));
         $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'page' => $this->context->smarty->fetch($this->template), 'token' => Tools::getToken(false));
         die(Tools::jsonEncode($return));
     }
 }
Exemplo n.º 26
0
 public function run()
 {
     DB::table('genders')->delete();
     Gender::create(array('description' => 'Hombre'));
     Gender::create(array('description' => 'Mujer'));
 }
Exemplo n.º 27
0
 /**
  * 
  * @param int $nefubId
  */
 public function showClub($nefubId)
 {
     $this->subdirectory = '/club';
     $this->path = '/' . $nefubId;
     $this->template = '/club/club.tpl';
     if ($this->getClearRender()) {
         $oClub = Club::getByNefubId($nefubId);
         if ($oClub) {
             $competitionGenders = array('Heren', 'Dames', 'Mixed');
             $aCompetitions = array();
             foreach ($competitionGenders as $competitionGender) {
                 $oGender = Gender::getByNefubName($competitionGender);
                 $aGenreCompetitions = Competition::getAll(array('gender_id' => $oGender->getId(), 'season_nefub_id' => $this->season->nefub_id), 'genre_id`,`name');
                 $aCompetitions = array_merge($aCompetitions, $aGenreCompetitions);
             }
             $aCompetitionTeams = array();
             foreach ($aCompetitions as $oCompetition) {
                 $aTeams = Team::getAll(array('competition_nefub_id' => $oCompetition->nefub_id, 'club_nefub_id' => $oClub->nefub_id, 'season_nefub_id' => $oCompetition->season_nefub_id), 'name');
                 if (count($aTeams)) {
                     $aCompetitionTeams[] = array('competition' => $oCompetition, 'teams' => $aTeams);
                 }
             }
             $this->assign('oClub', $oClub);
             $this->assign('aCompetitionTeams', $aCompetitionTeams);
         } else {
             $this->redirect();
         }
     }
     $this->showOutput();
 }
Exemplo n.º 28
0
 public function load_form($form_id = NULL)
 {
     if ($form_id == "patient_details") {
         $data['pob'] = District::getItems();
         $data['gender'] = Gender::getItems();
         $data['current_status'] = Patient_Status::getItems();
         $data['source'] = Patient_Source::getItems();
         $data['drug_prophylaxis'] = Drug_Prophylaxis::getItems();
         $data['service'] = Regimen_Service_Type::getItems();
         $data['fplan'] = Family_Planning::getItems();
         $data['other_illnesses'] = Other_Illnesses::getItems();
         $data['pep_reason'] = Pep_Reason::getItems();
         $data['drug_allergies'] = Drugcode::getItems();
         $regimens = Regimen::getItems();
         $data['start_regimen'] = $regimens;
         $data['current_regimen'] = $regimens;
         $data['who_stage'] = Who_Stage::getItems();
         //Get facilities beacuse of UTF-8 encoding
         $this->db->select('facilitycode AS id, name AS Name');
         $query = $this->db->get('facilities');
         $facilities = $query->result_array();
         foreach ($facilities as $facility) {
             $facility_list[] = array('id' => $facility['id'], 'Name' => utf8_encode($facility['Name']));
         }
         $data['transfer_from'] = $facility_list;
     }
     echo json_encode($data);
 }
 protected function initCustomerList()
 {
     $genders_icon = array('default' => 'unknown.gif');
     $genders = array(0 => $this->l('?'));
     foreach (Gender::getGenders() as $gender) {
         $genders_icon[$gender->id] = '../genders/' . (int) $gender->id . '.jpg';
         $genders[$gender->id] = $gender->name;
     }
     $this->fields_list['customers'] = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'id_gender' => array('title' => $this->l('Social title'), 'align' => 'center', 'icon' => $genders_icon, 'list' => $genders, 'width' => 25), 'firstname' => array('title' => $this->l('First Name'), 'align' => 'left', 'width' => 150), 'lastname' => array('title' => $this->l('Name'), 'align' => 'left', 'width' => 'auto'), 'email' => array('title' => $this->l('Email address'), 'align' => 'left', 'width' => 250), 'birthday' => array('title' => $this->l('Birth date'), 'align' => 'center', 'type' => 'date', 'width' => 75), 'date_add' => array('title' => $this->l('Registration date'), 'align' => 'center', 'type' => 'date', 'width' => 75), 'orders' => array('title' => $this->l('Orders'), 'align' => 'center', 'width' => 50), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'width' => 25));
 }
Exemplo n.º 30
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     /* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
     if (empty($this->context->cart->id_carrier)) {
         $checked = $this->context->cart->simulateCarrierSelectedOutput();
         $checked = (int) Cart::desintifier($checked);
         $this->context->cart->id_carrier = $checked;
         $this->context->cart->update();
         CartRule::autoRemoveFromCart($this->context);
         CartRule::autoAddToCart($this->context);
     }
     // SHOPPING CART
     $this->_assignSummaryInformations();
     // WRAPPING AND TOS
     $this->_assignWrappingAndTOS();
     if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
         $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
     } else {
         $countries = Country::getCountries($this->context->language->id, true);
     }
     // If a rule offer free-shipping, force hidding shipping prices
     $free_shipping = false;
     foreach ($this->context->cart->getCartRules() as $rule) {
         if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
             $free_shipping = true;
             break;
         }
     }
     $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => (int) Tools::getCountry(), 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => isset($_GET['isPaymentStep']) && $_GET['isPaymentStep'], 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
     $years = Tools::dateYears();
     $months = Tools::dateMonths();
     $days = Tools::dateDays();
     $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days));
     /* Load guest informations */
     if ($this->isLogged && $this->context->cookie->is_guest) {
         $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
     }
     // ADDRESS
     if ($this->isLogged) {
         $this->_assignAddress();
     }
     // CARRIER
     $this->_assignCarrier();
     // PAYMENT
     $this->_assignPayment();
     Tools::safePostVars();
     $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active;
     $this->context->smarty->assign('newsletter', $newsletter);
     $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN'));
     $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
     $this->_processAddressFormat();
     $link = new Link();
     if (Tools::getValue('deleteFromOrderLine')) {
         $id_product = Tools::getValue('id_product');
         $date_from = Tools::getValue('date_from');
         $date_to = Tools::getValue('date_to');
         $obj_cart_bk_data = new HotelCartBookingData();
         $cart_data_dlt = $obj_cart_bk_data->deleteRoomDataFromOrderLine($this->context->cart->id, $this->context->cart->id_guest, $id_product, $date_from, $date_to);
         if ($cart_data_dlt) {
             Tools::redirect($link->getPageLink('order', null, $this->context->language->id));
         }
     }
     if ((bool) Configuration::get('PS_ADVANCED_PAYMENT_API')) {
         $this->addJS(_THEME_JS_DIR_ . 'advanced-payment-api.js');
         $this->setTemplate(_PS_THEME_DIR_ . 'order-opc-advanced.tpl');
     } else {
         if (Module::isInstalled('hotelreservationsystem')) {
             require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php';
             $obj_cart_bk_data = new HotelCartBookingData();
             $obj_htl_bk_dtl = new HotelBookingDetail();
             $obj_rm_type = new HotelRoomType();
             $htl_rm_types = $this->context->cart->getProducts();
             if (!empty($htl_rm_types)) {
                 foreach ($htl_rm_types as $type_key => $type_value) {
                     $product = new Product($type_value['id_product'], false, $this->context->language->id);
                     $cover_image_arr = $product->getCover($type_value['id_product']);
                     if (!empty($cover_image_arr)) {
                         $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default');
                     } else {
                         $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default');
                     }
                     $unit_price = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                     if (isset($this->context->customer->id)) {
                         $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
                     } else {
                         $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
                     }
                     $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['id_product']);
                     $cart_htl_data[$type_key]['id_product'] = $type_value['id_product'];
                     $cart_htl_data[$type_key]['cover_img'] = $cover_img;
                     $cart_htl_data[$type_key]['name'] = $product->name;
                     $cart_htl_data[$type_key]['unit_price'] = $unit_price;
                     $cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
                     $cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
                     foreach ($cart_bk_data as $data_k => $data_v) {
                         $date_join = strtotime($data_v['date_from']) . strtotime($data_v['date_to']);
                         if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
                             $num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
                             $vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] * $num_days;
                             $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                             $amount *= $vart_quant;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                         } else {
                             $num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
                             $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                             $amount *= $num_days;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['link'] = $link->getPageLink('order', null, $this->context->language->id, "id_product=" . $type_value['id_product'] . "&deleteFromOrderLine=1&date_from=" . $data_v['date_from'] . "&date_to=" . $data_v['date_to']);
                         }
                     }
                 }
                 $this->context->smarty->assign('cart_htl_data', $cart_htl_data);
             }
         }
         $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl');
     }
 }