Inheritance: extends admin_manager_base
/**
 * Render cabinet properties into this view.
 *
 * The cabinet properties zone, row, model, maximum weight and installation date
 * are rendered to be for this page. It checks if the user is allowed to see the
 * content of the cabinet and only if the user does the information is provided.
 *
 * @param Cabinet $cab
 * @param CabinetAudit $audit
 * @param string $AuditorName
 */
function renderCabinetProps($cab, $audit, $AuditorName)
{
    $tmpDC = new DataCenter();
    $tmpDC->DataCenterID = $cab->DataCenterID;
    $tmpDC->GetDataCenter();
    $AuditorName = $AuditorName != '' ? "<br>{$AuditorName}" : "";
    $renderedHTML = "\t\t<table id=\"cabprop\">\n\t\t\t<tr><td>" . __("Last Audit") . ":</td><td id=\"lastaudit\">{$audit->AuditStamp}{$AuditorName}</td></tr>\n\t\t\t<tr><td>" . __("Model") . ":</td><td>{$cab->Model}</td></tr>\n\t\t\t<tr><td>" . __("Data Center") . ":</td><td>{$tmpDC->Name}</td></tr>\n\t\t\t<tr><td>" . __("Install Date") . ":</td><td>{$cab->InstallationDate}</td></tr>\n";
    if ($cab->ZoneID) {
        $zone = new Zone();
        $zone->ZoneID = $cab->ZoneID;
        $zone->GetZone();
        $renderedHTML .= "\t\t\t<tr><td>" . __("Zone") . ":</td><td>{$zone->Description}</td></tr>\n";
    }
    if ($cab->CabRowID) {
        $cabrow = new CabRow();
        $cabrow->CabRowID = $cab->CabRowID;
        $cabrow->GetCabRow();
        $renderedHTML .= "\t\t\t<tr><td>" . __("Row") . ":</td><td>{$cabrow->Name}</td></tr>\n";
    }
    $renderedHTML .= "\t\t\t<tr><td>" . __("Tags") . ":</td><td>" . renderTagsToString($cab) . "</td></tr>\n";
    //   This is out of context here and makes the information confusing.
    //    $renderedHTML .= '			<tr><td class="left">' . __('Front Edge') . ':</td>';
    //    $renderedHTML .= "<td class=\"right\">$cab->FrontEdge </td></tr>\n";
    $renderedHTML .= "\t\t</table>\n";
    return $renderedHTML;
}
示例#2
0
function port($type = 0, $_pays = false, $_cpostal = "")
{
    if ($_SESSION['navig']->commande->transport == "" && !$type) {
        return -1;
    }
    if ($_SESSION['navig']->adresse != 0) {
        $chadr = 1;
    } else {
        $chadr = 0;
    }
    $modules = new Modules();
    if (!$type) {
        $modules->charger_id($_SESSION['navig']->commande->transport);
    } else {
        $modules->charger_id($type);
    }
    if ($modules->type != Modules::TRANSPORT || !$modules->actif) {
        return -1;
    }
    $p = new Pays();
    if ($chadr) {
        $adr = new adresse();
        $adr->charger($_SESSION['navig']->adresse);
        $p->charger($adr->pays);
        $cpostal = $adr->cpostal;
    } else {
        $p->charger($_SESSION['navig']->client->pays);
        $cpostal = $_SESSION['navig']->client->cpostal;
    }
    // Prise en compte des infos passée, si aucune des infos précédentes n'est pertinente.
    if (empty($p->id) && $_pays) {
        $p->charger($_pays);
    }
    if (empty($cpostal) && $_cpostal != "") {
        $cpostal = $_cpostal;
    }
    $zone = new Zone();
    $zone->charger($p->zone);
    try {
        $port = ActionsModules::instance()->instancier($modules->nom);
        $port->nbart = $_SESSION['navig']->panier->nbart();
        $port->poids = $_SESSION['navig']->panier->poids();
        $port->total = $_SESSION['navig']->panier->total();
        $port->zone = $p->zone;
        $port->pays = $p->id;
        $port->unitetr = $zone->unite;
        $port->cpostal = $cpostal;
        $frais = $port->calcule();
        ActionsModules::instance()->appel_module("port", $frais);
        return $frais;
    } catch (exception $e) {
        return -1;
    }
}
 public function run($request)
 {
     $zone = new Zone();
     $zone->Name = "International";
     $zone->Description = "All countries";
     $zone->write();
     $countries = ShopConfig::current()->getCountriesList();
     foreach ($countries as $code => $country) {
         $zoneregion = new ZoneRegion(array('ZoneID' => $zone->ID, 'Country' => $code));
         $zoneregion->write();
         echo ".";
     }
 }
示例#4
0
 public function destroy($id)
 {
     if (Auth::user()->is_admin) {
         $count = 0;
         $zone = Zone::find($id);
         $clients = Client::select('zone_id')->get();
         foreach ($clients as $key => $client) {
             $u = $client->zone_id;
             $uarray = explode(',', $u);
             if (in_array($id, $uarray, true)) {
                 $count = $count + 1;
             }
         }
         if ($count > 0) {
             $field = $count == 1 ? ' ' : 's';
             $field2 = $count == 1 ? ' pertenece' : ' pertenecen';
             $message = $count . " Cliente" . $field . $field2 . " a la zona " . $zone->name;
             Session::flash('error', $message);
             return Redirect::to('zonas/' . $id);
         } else {
             $zone->delete();
             $message = "Zona Eliminada con éxito";
             Session::flash('message', $message);
             return Redirect::to('zonas');
         }
     }
 }
 public function check(Discount $discount)
 {
     $zones = $discount->Zones();
     if (!$zones->exists()) {
         return true;
     }
     $address = $this->order->getShippingAddress();
     if (!$address) {
         $this->error(_t("OrderCouponModifier.NOTINZONE", "This coupon can only be used for a specific shipping location."));
         return false;
     }
     $currentzones = Zone::get_zones_for_address($address);
     if (!$currentzones || !$currentzones->exists()) {
         $this->error(_t("OrderCouponModifier.NOTINZONE", "This discount can only be used for a specific shipping location."));
         return false;
     }
     //check if any of currentzones is in zones
     $inzone = false;
     foreach ($currentzones as $zone) {
         if ($zones->find('ID', $zone->ID)) {
             $inzone = true;
             break;
         }
     }
     if (!$inzone) {
         $this->error(_t("OrderCouponModifier.NOTINZONE", "This discount can only be used for a specific shipping location."));
         return false;
     }
     return true;
 }
 public function state($country_id)
 {
     if (!empty($country_id)) {
         //$cid = explode(",",$_POST[])
         return Zone::find_by_sql("SELECT * FROM zone WHERE country_id={$country_id}");
     }
 }
示例#7
0
 public function zone_fork($disposition_id, $disposition, $url, $theme, $page, $zone)
 {
     $url = str_replace(url(), '', $url);
     if (!$url || preg_match('#^index(?:\\.|/)#', $url)) {
         $url = '/';
     }
     if (extension($url) == 'html') {
         $url = substr($url, 0, -5) . '/*';
     }
     $url = explode('/', $url);
     if (!empty($url[0]) && ($module = $this->load->module($url[0])) && !empty($module->routes) && ($method = $module->get_method(array_slice($url, 1, -1), TRUE))) {
         $url = array($url[0], $method, '*');
     }
     $url = implode('/', $url);
     if ($page == '*' || !$this->db->select('1')->from('nf_dispositions')->where('page', $url)->row()) {
         foreach ($disposition as &$rows) {
             foreach ($rows->cols as &$col) {
                 foreach ($col->widgets as &$w) {
                     $widget = $this->db->select('widget', 'type', 'title', 'settings')->from('nf_widgets')->where('widget_id', $w->widget_id)->row();
                     $w->widget_id = $this->db->insert('nf_widgets', array('widget' => $widget['widget'], 'type' => $widget['type'], 'title' => $widget['title'], 'settings' => $widget['settings']));
                 }
             }
         }
         return Zone::display($this->db->insert('nf_dispositions', array('theme' => $theme, 'page' => $url, 'zone' => $zone, 'disposition' => serialize($disposition))), $disposition, $url, $zone, TRUE);
     } else {
         $this->model()->delete_disposition($disposition);
         $this->db->where('disposition_id', $disposition_id)->delete('nf_dispositions');
         $disposition = $this->db->select('disposition_id', 'disposition')->from('nf_dispositions')->where('theme', $theme)->where('page', '*')->where('zone', $zone)->row();
         return Zone::display($disposition['disposition_id'], unserialize($disposition['disposition']), '*', $zone, TRUE);
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     $site = Site::find($id);
     $zones = Zone::all();
     $data = array('page' => 'sites', 'tab' => 'manage', 'site' => $site, 'zones' => $zones);
     return View::make('site_zone.index', $data);
 }
示例#9
0
 public function actionCreate()
 {
     $model = new Zone();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Zone'])) {
         $model->attributes = $_POST['Zone'];
         if ($model->save()) {
             Flashes::addInfoFlash(Yii::t('amo', 'Zone created successfully'));
             $this->redirect(array('view', 'id' => $model->zid));
         } else {
             Flashes::addErrorFlash(Yii::t('amo', 'Could not create the zone.') . '  ' . Yii::t('amo', 'Please, try again later.'));
         }
     }
     $this->render('create', array('model' => $model));
 }
    public function renderForm()
    {
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
        if ($value = Tools::getValue('address_layout')) {
            $address_layout = $value;
        }
        $default_layout = '';
        $default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
        foreach ($default_layout_tab as $line) {
            $default_layout .= implode(' ', $line) . "\r\n";
        }
        $this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'image' => '../img/admin/world.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country:'), 'name' => 'name', 'lang' => true, 'size' => 30, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Country name')), array('type' => 'text', 'label' => $this->l('ISO code:'), 'name' => 'iso_code', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Two -- or three -- letter ISO code (e.g. U.S. for United States)') . '.
							<a href="http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm" target="_blank">' . $this->l('Official list here') . '
							</a>.'), array('type' => 'text', 'label' => $this->l('Call prefix:'), 'name' => 'call_prefix', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('International call prefix, (e.g. 1 for United States)')), array('type' => 'select', 'label' => $this->l('Default currency:'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone:'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'desc' => $this->l('Geographical region')), array('type' => 'radio', 'label' => $this->l('Need zip/postal code:'), 'name' => 'need_zip_code', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/post code format:'), 'name' => 'zip_code_format', 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Zip Code format (L for a letter, N for a number and C for the ISO code). For example, NNNNN for the United States. No verification if undefined.')), array('type' => 'address_layout', 'label' => $this->l('Address format:'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields()), array('type' => 'radio', 'label' => $this->l('Address Standardization:'), 'name' => 'standardization', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'standardization_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'standardization_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Active:'), '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('Display this country to your customers (the selected country will always be displayed in the Back Office)')), array('type' => 'radio', 'label' => $this->l('Contains following  states:'), 'name' => 'contains_states', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Display tax label (e.g. "Tax incl."):'), 'name' => 'display_tax_label', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
        if (Shop::isFeatureActive()) {
            $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
        }
        $this->fields_form['submit'] = array('title' => $this->l('Save   '), 'class' => 'button');
        if ($this->object->iso_code == 'US') {
            $this->object->standardization = Configuration::get('PS_TAASC');
        }
        return parent::renderForm();
    }
 public function add($nom)
 {
     $this->nom = $nom;
     $this->unite = 0;
     $this->id = parent::add();
     redirige("zone.php?id=" . $this->id . "&action=showZone#zone");
 }
 function calculateRate(ShippingPackage $package, $address)
 {
     $rate = null;
     $ids = Zone::get_zones_for_address($address);
     if (!$ids) {
         return $rate;
     }
     $ids = $ids->map('ID', 'ID');
     $packageconstraints = array("Weight" => 'weight', "Volume" => 'volume', "Value" => 'value', "Quantity" => 'quantity');
     $constraintfilters = array();
     foreach ($packageconstraints as $db => $pakval) {
         $mincol = "\"ZonedShippingRate\".\"{$db}Min\"";
         $maxcol = "\"ZonedShippingRate\".\"{$db}Max\"";
         $constraintfilters[] = "(" . "{$mincol} >= 0" . " AND {$mincol} <= " . $package->{$pakval}() . " AND {$maxcol} > 0" . " AND {$maxcol} >= " . $package->{$pakval}() . " AND {$mincol} < {$maxcol}" . ")";
     }
     $filter = "(" . implode(") AND (", array("\"ZonedShippingMethodID\" = " . $this->ID, "\"ZoneID\" IN(" . implode(",", $ids) . ")", implode(" OR ", $constraintfilters))) . ")";
     //order by zone specificity
     $orderby = "";
     if (count($ids) > 1) {
         $orderby = "CASE \"ZonedShippingRate\".\"ZoneID\"";
         $count = 1;
         foreach ($ids as $id) {
             $orderby .= " WHEN {$id} THEN {$count} ";
             $count++;
         }
         $orderby .= "ELSE {$count} END ASC,";
     }
     $orderby .= "\"ZonedShippingRate\".\"Rate\" ASC";
     if ($sr = DataObject::get_one("ZonedShippingRate", $filter, true, $orderby)) {
         $rate = $sr->Rate;
     }
     $this->CalculatedRate = $rate;
     return $rate;
 }
示例#13
0
    function getContent()
    {
        $configKeys = array('EBAY_SECURITY_TOKEN', 'PS_LANG_DEFAULT');
        // Load prestashop ebay's configuration
        $configs = Configuration::getMultiple($configKeys);
        $profile_configs = $this->ebay_profile->getMultiple(array('EBAY_DELIVERY_TIME', 'EBAY_ZONE_NATIONAL', 'EBAY_ZONE_INTERNATIONAL'));
        // Check if the module is configured
        if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) {
            $template_vars = array('error_form_shipping' => 'true');
            return $this->display('error_paypal_email.tpl', $template_vars);
        }
        $nb_shipping_zones_excluded = DB::getInstance()->getValue('SELECT COUNT(*) 
			FROM ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded
			WHERE `id_ebay_profile` = ' . (int) $this->ebay_profile->id);
        if (!$nb_shipping_zones_excluded) {
            EbayShippingZoneExcluded::loadEbayExcludedLocations($this->ebay_profile->id);
        }
        $module_filters = version_compare(_PS_VERSION_, '1.4.5', '>=') ? Carrier::CARRIERS_MODULE : 2;
        //INITIALIZE CACHE
        $psCarrierModule = $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT'], false, false, false, null, $module_filters);
        $url_vars = array('id_tab' => '3', 'section' => 'shipping');
        if (version_compare(_PS_VERSION_, '1.5', '>')) {
            $url_vars['controller'] = Tools::getValue('controller');
        } else {
            $url_vars['tab'] = Tools::getValue('tab');
        }
        $zones = Zone::getZones(true);
        foreach ($zones as &$zone) {
            $zone['carriers'] = Carrier::getCarriers($this->context->language->id, false, false, $zone['id_zone']);
        }
        $template_vars = array('eBayCarrier' => EbayShippingService::getCarriers($this->ebay_profile->ebay_site_id), 'psCarrier' => $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT']), 'psCarrierModule' => $psCarrierModule, 'existingNationalCarrier' => EbayShipping::getNationalShippings($this->ebay_profile->id), 'existingInternationalCarrier' => EbayShippingInternationalZone::getExistingInternationalCarrier($this->ebay_profile->id), 'deliveryTime' => $profile_configs['EBAY_DELIVERY_TIME'], 'prestashopZone' => Zone::getZones(), 'excludeShippingLocation' => EbayShippingZoneExcluded::cacheEbayExcludedLocation($this->ebay_profile->id), 'internationalShippingLocations' => EbayShippingLocation::getInternationalShippingLocations(), 'deliveryTimeOptions' => EbayDeliveryTimeOptions::getDeliveryTimeOptions(), 'formUrl' => $this->_getUrl($url_vars), 'ebayZoneNational' => isset($profile_configs['EBAY_ZONE_NATIONAL']) ? $profile_configs['EBAY_ZONE_NATIONAL'] : false, 'ebayZoneInternational' => isset($profile_configs['EBAY_ZONE_INTERNATIONAL']) ? $profile_configs['EBAY_ZONE_INTERNATIONAL'] : false, 'ebay_token' => $configs['EBAY_SECURITY_TOKEN'], 'id_ebay_profile' => $this->ebay_profile->id, 'newPrestashopZone' => $zones);
        return $this->display('shipping.tpl', $template_vars);
    }
示例#14
0
 public function actionUpdate($id)
 {
     $model = new SettingsForm();
     if (isset($_POST['SettingsForm'])) {
         $model->attributes = $_POST['SettingsForm'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromStore($id);
     }
     $directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
     $themes = array();
     foreach ($directories as $directory) {
         $themes[] = basename($directory);
     }
     $layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
     $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
     $zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
     $languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
     $currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
     $yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
     $lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
     $weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
     $taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
     $customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
     $informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
     // TODO: localisation
     $orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
     // TODO: localisation
     $returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
     $mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
     $this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
 }
示例#15
0
 public function getcomboboxesAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         if (!$this->getRequest()->isXmlHttpRequest()) {
             $this->view->msg = 'Not Ajax Request';
             $this->_forward('error', 'error');
         } else {
             $zones = Zone::getAllZones();
             $contexts = Context::getAllContexts();
             $agents = Agent::getAllAgents();
             $this->view->zones = $zones;
             $this->view->agents = $agents;
             $this->view->contexts = $contexts;
             $this->render('aclcomboboxes');
         }
     } else {
         if (!$this->getRequest()->isXmlHttpRequest()) {
             $this->view->msg = 'Not Ajax Request';
             $this->_forward('error', 'error');
         } else {
             $this->view->msg = 'Invalid User';
             $this->_forward('error', 'error');
         }
     }
 }
 public function xdInstall()
 {
     foreach ($this->Options->getValue('carrierList') as $carrier_key => $carrier_name) {
         $carrierId = \Configuration::get($carrier_key);
         $deleted = false;
         if ($carrierId > 0) {
             $carrier = new \Carrier($carrierId);
             $deleted = $carrier->deleted;
         }
         if ($carrierId < 1 || $deleted) {
             // Create carrier
             $carrier = new \Carrier();
             $carrier->name = $carrier_name;
             $carrier->id_tax_rules_group = 0;
             $carrier->active = 1;
             $carrier->deleted = 0;
             foreach (\Language::getLanguages(true) as $language) {
                 // TODO Carrier delay
                 $carrier->delay[(int) $language['id_lang']] = ' ';
             }
             $carrier->shipping_handling = 0;
             $carrier->range_behavior = 1;
             $carrier->is_module = 1;
             $carrier->shipping_external = 1;
             $carrier->external_module_name = $this->moduleInstance->name;
             $carrier->need_range = 1;
             if (!$carrier->add()) {
                 return false;
             }
             // Associate carrier to all groups
             $groups = \Group::getGroups(true);
             foreach ($groups as $group) {
                 \Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']));
             }
             // Create price range
             $rangePrice = new \RangePrice();
             $rangePrice->id_carrier = $carrier->id;
             $rangePrice->delimiter1 = '0';
             $rangePrice->delimiter2 = '10000';
             $rangePrice->add();
             // Create weight range
             $rangeWeight = new \RangeWeight();
             $rangeWeight->id_carrier = $carrier->id;
             $rangeWeight->delimiter1 = '0';
             $rangeWeight->delimiter2 = '10000';
             $rangeWeight->add();
             // Associate carrier to all zones
             $zones = \Zone::getZones(true);
             foreach ($zones as $zone) {
                 \Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
                 \Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
                 \Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
             }
             copy(self::$instanceBaseDir . '/img/logo.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
             \Configuration::updateValue($carrier_key, $carrier->id);
         }
     }
     return true;
 }
示例#17
0
 public function __construct(Zone $z = null)
 {
     if ($z === null) {
         $z = Zone::zone0();
     }
     $this->upHost = $z->upHost;
     $this->upHostBackup = $z->upHostBackup;
 }
 public function __construct($model = null)
 {
     $this->name = "pda eShop";
     $this->owner = "pda";
     $this->country = Country::whereName("Greece")->first();
     if ($this->country != null) {
         $this->zone = Zone::where('country_id', $this->country->id)->where('name', 'Attica')->first();
     }
 }
示例#19
0
 public function run()
 {
     DB::table('zones')->delete();
     Zone::create(array('name' => 'Gulshan'));
     Zone::create(array('name' => 'Baridhara'));
     Zone::create(array('name' => 'Uttara'));
     Zone::create(array('name' => 'Motijheel'));
     Zone::create(array('name' => 'Mirpur'));
 }
 function testLocalRates()
 {
     $address_loc = $this->objFromFixture("Address", "wnz6022");
     //New Zealand address
     Zone::cache_zone_ids($address_loc);
     //weight based
     $type = "weight";
     $this->assertMatch($type, $this->p0, $address_loc, 4);
     //weight = 0kg
     $this->assertMatch($type, $this->p1, $address_loc, 4);
     //weight = 2.34kg
     $this->assertMatch($type, $this->p2, $address_loc, 48);
     //weight= 17kg,
     $this->assertMatch($type, $this->p3, $address_loc, 58);
     //weight = 100kg
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //weight = 1000kg
     //volume based
     $type = "volume";
     $this->assertMatch($type, $this->p0, $address_loc, 1);
     //volume = 0cm3
     $this->assertMatch($type, $this->p1, $address_loc, 1);
     //volume = 1cm3
     $this->assertMatch($type, $this->p2, $address_loc, 3);
     //volume = 6cm3
     $this->assertMatch($type, $this->p3, $address_loc, 520);
     //volume = 18927.783cm3
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //volume = 2000000cm3
     //value based
     $type = "value";
     $this->assertMatch($type, $this->p0, $address_loc, 1);
     //value = $0
     $this->assertMatch($type, $this->p1, $address_loc, 1);
     //value = $2
     $this->assertMatch($type, $this->p2, $address_loc, 3);
     //value = $6
     $this->assertNoMatch($type, $this->p3, $address_loc);
     //value = $1000
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //value = $1,000,000
     //quantity based
     $type = "quantity";
     $this->assertNoMatch($type, $this->p0, $address_loc);
     //quantity = 0
     $this->assertMatch($type, $this->p1, $address_loc, 5.5);
     //quantity = 3
     $this->assertMatch($type, $this->p2, $address_loc, 9.300000000000001);
     //quantity = 10
     $this->assertNoMatch($type, $this->p3, $address_loc);
     //quantity = 155
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //quantity = 12412
 }
示例#21
0
 /**
  * load initail data for employee form needed during 
  * creating and editing employee
  * data 
  */
 public function getData()
 {
     global $database;
     $depts = Department::find_all();
     $role = Roles::find_all();
     $country = Country::find_all();
     $vendors = Vendor::find_all();
     $zone = Zone::find_by_sql("SELECT * FROM zone");
     $startups = array("departs" => $depts, "country" => $country, "zone" => $zone, "vendors" => $vendors, "role" => $role);
     return $startups;
 }
 /**
  * load initail data for employee form needed during 
  * creating and editing employee
  * data 
  */
 public function getData()
 {
     global $database;
     $depts = Department::find_all();
     $role = Roles::find_all();
     $country = Country::find_all();
     $items = Items::find_all();
     $zone = Zone::find_by_sql("SELECT * FROM zone WHERE country_id=156");
     $startups = array("departs" => $depts, "country" => $country, "state" => $zone, "items" => $items, "role" => $role);
     return $startups;
 }
 public function run()
 {
     $this->trancate();
     $country = Country::whereName("Greece")->first();
     $zoneAttica = Zone::whereName("Attica")->first();
     $zoneIslands = Zone::whereName("Islands")->first();
     $geoZoneWithFPA23 = GeoZone::whereName("Geo Zone with FPA 23%")->first();
     $geoZoneWithFPA8 = GeoZone::whereName("Geo Zone with FPA 8%")->first();
     DB::table('zones_to_geo_zones')->insert(array('zone_id' => $zoneAttica->id, 'geo_zone_id' => $geoZoneWithFPA23->id));
     DB::table('zones_to_geo_zones')->insert(array('zone_id' => $zoneIslands->id, 'geo_zone_id' => $geoZoneWithFPA8->id));
 }
示例#24
0
 public function setShippingAddress(Address $address)
 {
     $this->order->ShippingAddressID = $address->ID;
     if (Member::currentUserID()) {
         $this->order->MemberID = Member::currentUserID();
     }
     $this->order->write();
     $this->order->extend('onSetShippingAddress', $address);
     //update zones and userinfo
     ShopUserInfo::singleton()->setAddress($address);
     Zone::cache_zone_ids($address);
 }
 /**
  * {@inheritdoc}
  */
 protected function createStatistics($type, $dateFrom, $dateTo = null, $id)
 {
     if (empty($dateFrom)) {
         throw new \InvalidArgumentException("{$dateFrom} is invalid, a valid dateFrom must be passed");
     }
     //Check type, create objects accordingly
     switch ($type) {
         case parent::PUBLISHER:
             $obj = new Publisher();
             break;
         case parent::WEBSITE:
             $obj = new Website();
             break;
         case parent::ZONE:
             $obj = new Zone();
             break;
         default:
             throw new \InvalidArgumentException("{$type} is not a valid statistics set");
     }
     $host = $obj->getAddress($id) . "&from=" . $dateFrom;
     if (!empty($dateTo)) {
         $host = $host . "&to=" . $dateTo;
     }
     //connect to the API service
     $connection = new Connection(new ArrayConfig(array("host" => $host, "key" => self::KEY, "sharedSecret" => self::SHARED_SECRET)));
     //get the response from API connection
     $arr = $connection->getResponse();
     //API returns everything under one element, load it
     $arr = $arr[0];
     //set stats from result
     $obj->setImpressions($arr["impressions"]);
     $obj->setClicks($arr["clicks"]);
     $obj->setRevenues($arr["revenue"]);
     return $obj;
 }
示例#26
0
文件: Zone.php 项目: Koulio/OpenZIS
 public static function setupContext($context)
 {
     if ($context == null && $context == '') {
         $_SESSION['CONTEXT_ID'] = 1;
     } else {
         if (!Zone::checkContextExist($context)) {
             echo '<FATAL_ERROR>INVALID CONTEXT</FATAL_ERROR>';
             exit;
         } else {
             $_SESSION['CONTEXT_ID'] = Zone::getContextId($context);
         }
     }
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $zone = Zone::model()->findAllByAttributes(array('district_id' => $id));
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['District'])) {
         $model->attributes = $_POST['District'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model, 'zone' => $zone));
 }
示例#28
0
 public function getData()
 {
     global $database;
     $depts = Department::find_all();
     $role = Roles::find_all();
     $country = Country::find_all();
     $vendors = Vendor::find_all();
     $countAcc = count(Cproduct::find_by_client($_SESSION["client_ident"]));
     $schedule = Cproduct::getNextSchedule($_SESSION["client_ident"]);
     $countTic = count(Ticket::find_by_client($_SESSION['client_ident']));
     $zone = Zone::find_by_sql("SELECT * FROM zone");
     $startups = array("departs" => $depts, "country" => $country, "zone" => $zone, "vendors" => $vendors, "role" => $role, "countProd" => $countAcc, "countTick" => $countTic, "Schel" => $schedule);
     return $startups;
 }
示例#29
0
 public function actionTreeFill()
 {
     $id = !isset($_GET['root']) ? 'source' : $_GET['root'];
     $dataTree = array();
     if ($id == 'source') {
         $root = Zone::model()->findByPk(0);
     } else {
         $root = Zone::model()->findByPk($id);
     }
     foreach ($root->children as $child) {
         $dataTree[] = array('id' => $child->zid, 'text' => CHtml::link($child->name, array('/zone/view/id/' . $child->zid)), 'collapsed' => $child->zid != 0, 'hasChildren' => true);
     }
     echo CTreeView::saveDataAsJson($dataTree);
 }
示例#30
0
 public function setCode($code)
 {
     if (is_null($code)) {
         $this->fv_error_message = $this->fv_error_message . '<br>- Código' . ERROR_NULL;
         return;
     }
     $codeZ = Zone::where('reg_code', $code)->select('reg_code')->first();
     if (!empty($codeZ->reg_code)) {
         $this->fv_error_message = $this->fv_error_message . '<br>- Código ' . ERROR_DUPLICADO;
         return;
     }
     $this->reg_code = $code;
     return $this;
 }