function postProcess()
 {
     // we retrieve the potential currencies to make sure the selected currency exists in this shop
     $currencies = TotCompatibility::getCurrenciesByIdShop($this->ebay_profile->id_shop);
     $currencies_ids = array_map(array($this, 'getCurrencyId'), $currencies);
     if ($this->ebay_profile->setConfiguration('EBAY_PAYPAL_EMAIL', pSQL(Tools::getValue('ebay_paypal_email'))) && $this->ebay_profile->setConfiguration('EBAY_SHOP', pSQL(Tools::getValue('ebay_shop'))) && $this->ebay_profile->setConfiguration('EBAY_SHOP_POSTALCODE', pSQL(Tools::getValue('ebay_shop_postalcode'))) && $this->ebay_profile->setConfiguration('EBAY_SHOP_COUNTRY', pSQL(Tools::getValue('ebay_shop_country'))) && $this->ebay_profile->setConfiguration('EBAY_LISTING_DURATION', Tools::getValue('listingdurations')) && $this->ebay_profile->setConfiguration('EBAY_AUTOMATICALLY_RELIST', Tools::getValue('automaticallyrelist')) && $this->ebay_profile->setReturnsPolicyConfiguration(pSQL(Tools::getValue('returnswithin')), pSQL(Tools::getValue('returnswhopays')), version_compare(_PS_VERSION_, '1.5', '>') ? Tools::nl2br(Tools::getValue('ebay_returns_description')) : nl2br2(Tools::getValue('ebay_returns_description')), pSQL(Tools::getValue('ebay_returns_accepted_option'))) && $this->ebay->setConfiguration('EBAY_ACTIVATE_MAILS', Tools::getValue('activate_mails') ? 1 : 0) && in_array((int) Tools::getValue('currency'), $currencies_ids) && $this->ebay_profile->setConfiguration('EBAY_CURRENCY', (int) Tools::getValue('currency')) && $this->ebay_profile->setConfiguration('EBAY_SEND_TRACKING_CODE', (int) Tools::getValue('send_tracking_code')) && $this->ebay_profile->setConfiguration('EBAY_SHIPPED_ORDER_STATE', (int) Tools::getValue('shipped_order_state')) && $this->ebay_profile->setConfiguration('EBAY_IMMEDIATE_PAYMENT', (int) Tools::getValue('immediate_payment'))) {
         return $this->ebay->displayConfirmation($this->ebay->l('Settings updated'));
     } else {
         return $this->ebay->displayError($this->ebay->l('Settings failed'));
     }
 }
Ejemplo n.º 2
0
 public function getFields()
 {
     parent::validateFields();
     $fields['id_customer'] = pSQL($this->id_customer);
     $fields['id_order'] = pSQL($this->id_order);
     $fields['state'] = pSQL($this->state);
     $fields['date_add'] = pSQL($this->date_add);
     $fields['date_upd'] = pSQL($this->date_upd);
     $fields['question'] = pSQL(nl2br2($this->question), true);
     return $fields;
 }
Ejemplo n.º 3
0
 public function processData()
 {
     if (Module::isInstalled('agilemultipleshop') && Shop::$id_shop_owner > 0) {
         if (!Validate::isLoadedObject($this->seller)) {
             $this->errors[] = Tools::displayError('Seller does not exist');
         } elseif (!$this->seller->active) {
             self::$smarty->assign('seller', $this->seller);
         } else {
             $rewrited_url = self::$link->getAgileSellerLink((int) $this->seller->id, $this->getSellerLinkRwrite());
             $this->seller_info->description = _PS_VERSION_ > '1.5' ? Tools::nl2br($this->seller_info->description) : nl2br2($this->seller_info->description);
             self::$smarty->assign('seller', $this->seller);
             self::$smarty->assign('seller_info', $this->seller_info);
             $sellermodule = new AgileMultipleSeller();
             $conf = Configuration::getMultiple($sellermodule->getCustomFields());
             $custom_labels = $sellermodule->getCustomLabels();
             self::$smarty->assign('conf', $conf);
             self::$smarty->assign('custom_labels', $custom_labels);
             $nbProducts = $this->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
             $this->pagination((int) $nbProducts);
             self::$smarty->assign('nb_products', (int) $nbProducts);
             $seller_products = $this->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay);
             AgileHelper::AssignProductImgs($seller_products);
             $si_1531_later = version_compare(_PS_VERSION_, '1.5.3.1', ">=");
             $HOOK_SELLER_RATINGS = '';
             if (Module::isInstalled('agilesellerratings')) {
                 require_once _PS_ROOT_DIR_ . "/modules/agilesellerratings/agilesellerratings.php";
                 $rmodule = new AgileSellerRatings();
                 $HOOK_SELLER_RATINGS = $rmodule->getAverageRating($this->id_seller, AgileSellerRatings::RATING_TYPE_SELLER);
             }
             self::$smarty->assign(array('products' => (isset($seller_products) and $seller_products) ? $seller_products : NULL, 'id_seller' => (int) $this->seller->id, 'path' => $this->seller_info->company, 'agilesellerproducts_tpl' => _PS_ROOT_DIR_ . "/modules/agilesellerproducts/", 'agilemultipleshop_tpl' => _PS_ROOT_DIR_ . "/modules/agilemultipleshop/", 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('category') : 'category'), 'mediumSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('medium') : 'medium'), 'thumbSceneSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('thumb_scene') : 'thumb_scene'), 'homeSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('home') : 'home'), 'HOOK_SELLER_RATINGS' => $HOOK_SELLER_RATINGS, 'page_name' => 'agileseller'));
             $ver = (int) str_replace(".", "", _PS_VERSION_);
             if ($ver <= 1430) {
             } else {
                 if ($ver <= 1451) {
                     if (isset(self::$cookie->id_customer)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer));
                     } elseif (isset(self::$cookie->id_guest)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest));
                     }
                 } else {
                     if (isset(self::$cookie->id_compare)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) self::$cookie->id_compare));
                     }
                 }
             }
         }
         self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
     }
 }
 public function process()
 {
     parent::process();
     if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) {
         $this->errors[] = Tools::displayError('Missing category ID');
     } else {
         if (!Validate::isLoadedObject($this->category)) {
             $this->errors[] = Tools::displayError('Category does not exist');
         } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) {
             $this->errors[] = Tools::displayError('You do not have access to this category.');
         } elseif (!$this->category->active) {
             self::$smarty->assign('category', $this->category);
         } else {
             $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite);
             /* Scenes  (could be externalised to another controler if you need them */
             self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false));
             /* Scenes images formats */
             if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) {
                 foreach ($sceneImageTypes as $sceneImageType) {
                     if ($sceneImageType['name'] == 'thumb_scene') {
                         $thumbSceneImageType = $sceneImageType;
                     } elseif ($sceneImageType['name'] == 'large_scene') {
                         $largeSceneImageType = $sceneImageType;
                     }
                 }
                 self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
                 self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
             }
             $this->category->description = nl2br2($this->category->description);
             $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang);
             self::$smarty->assign('category', $this->category);
             if (isset($subCategories) and !empty($subCategories) and $subCategories) {
                 self::$smarty->assign('subcategories', $subCategories);
                 self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
             }
             if ($this->category->id != 1) {
                 $this->productListAssign();
             }
             self::$smarty->assign(array('products' => (isset($this->cat_products) and $this->cat_products) ? $this->cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home')));
             if (isset(self::$cookie->id_customer)) {
                 self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer));
             } elseif (isset(self::$cookie->id_guest)) {
                 self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest));
             }
         }
     }
     self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
 }
Ejemplo n.º 5
0
 public function hookPaymentReturn($params)
 {
     if (!$this->active) {
         return;
     }
     global $smarty;
     $state = $params['objOrder']->getCurrentState();
     if ($state == Configuration::get('PS_OS_CHEQUE') or $state == Configuration::get('PS_OS_OUTOFSTOCK')) {
         $smarty->assign(array('total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false), 'chequeName' => $this->chequeName, 'chequeAddress' => nl2br2($this->address), 'status' => 'ok', 'id_order' => $params['objOrder']->id));
     } else {
         $smarty->assign('status', 'failed');
     }
     return $this->display(__FILE__, 'payment_return.tpl');
 }
Ejemplo n.º 6
0
// if we want our own tpl name, we can "steal" translations from other tpl files using our l2
include_once dirname(__FILE__) . '/../../Helpers.php';
CartAPI_Handlers_Helpers::preInit();
require_once dirname(__FILE__) . '/../../../../init.php';
include dirname(__FILE__) . '/bankwire.php';
// create an instance of the payment module
$bankwire = new CartAPI_Module_BankWire();
// get some extra params
$cartOrder = getCartOrder();
if ($cartOrder === FALSE) {
    die("ERROR: Cannot get cart order");
}
$orderTotal = $cartOrder->total_paid;
$cartCurrency = new Currency((int) $cartOrder->id_currency);
// set some smarty params
$smarty->assign(array('total_to_pay' => Tools::displayPrice($orderTotal, $cartCurrency, false), 'bankwireDetails' => nl2br2($bankwire->details), 'bankwireAddress' => nl2br2($bankwire->address), 'bankwireOwner' => $bankwire->owner, 'id_order' => (int) $cartOrder->id));
// output
$smarty->force_compile = true;
// remove after tpl debug
$smarty->display(dirname(__FILE__) . '/success.tpl');
//////////////////////////////////////////////////////////////////////////
function getCartOrder()
{
    global $cart;
    $id_order = Order::getOrderByCartId((int) $cart->id);
    if (!$id_order) {
        return false;
    }
    $cartOrder = new Order((int) $id_order);
    if (!Validate::isLoadedObject($cartOrder)) {
        return false;
Ejemplo n.º 7
0
 public function getContent()
 {
     if (Tools::isSubmit('addNewSlide')) {
         $this->_createNewSlide();
     }
     foreach ($this->kinkyslider_output_images as $slideToUpdate) {
         if (Tools::isSubmit($this->name . '_deleteslide_' . $slideToUpdate['kinky_id'])) {
             $this->_deleteSlide($slideToUpdate['kinky_id']);
         }
     }
     if (Tools::isSubmit('updateSlides')) {
         foreach ($this->kinkyslider_output_images as $slideToUpdate) {
             $_thisID = $slideToUpdate['kinky_id'];
             $_thisLink = $slideToUpdate['kinky_link'];
             $_thisImageDir = $slideToUpdate['kinky_imagedir'];
             $_thisHeader = $slideToUpdate['kinky_header'];
             $_thisPrice = $slideToUpdate['kinky_price'];
             $_thisOrder = $slideToUpdate['kinky_order'];
             $_thisActive = $slideToUpdate['kinky_active'];
             $_thisSlideIsChanged = false;
             /* Let's see if the user wanted to upload an image for this slide ID
              * If so, we'll create a new directory on the server, move the uploaded image there,
              * Scale the image to the width & height given in the configuration and
              * Then save it as JPEG image.
              */
             if (isset($_FILES[$this->name . '_image' . $_thisID]) and isset($_FILES[$this->name . '_image' . $_thisID]['tmp_name']) and !empty($_FILES[$this->name . '_image' . $_thisID]['tmp_name'])) {
                 if ($error = @checkImage($_FILES[$this->name . '_image' . $_thisID], 4000000)) {
                     $this->_postErrors[] = $error;
                 } else {
                     $_last_picture_dir = $this->bazinga_last_dir('images');
                     $_numeric_last_picture_dir = (int) $_last_picture_dir;
                     $_new_picture_dir = $_numeric_last_picture_dir + 1;
                     $_target_path = dirname(__FILE__) . '/uploads/images/' . $_new_picture_dir . '/';
                     mkdir(str_replace('//', '/', $_target_path), 0755, true);
                     if (move_uploaded_file($_FILES[$this->name . '_image' . $_thisID]['tmp_name'], $_target_path . KINKYSLIDER_DEFAULT_FILE_NAME . '.png')) {
                         // $this->bazinga_load($_target_path.$_FILES[$this->name.'_image'.$_thisID]['name']);
                         // $this->bazinga_resizeZoomCrop($this->kinkyslider_calculated_image_width,$this->kinkyslider_calculated_image_height);
                         //$this->bazinga_save($_target_path.KINKYSLIDER_DEFAULT_FILE_NAME.'.png');
                         $_thisImageDir = $_new_picture_dir;
                         $_thisSlideIsChanged = true;
                     }
                 }
             }
             if ($_checkUpdate = Tools::getValue($this->name . '_link' . $_thisID)) {
                 $this->_linkValidation($_checkUpdate);
                 if (!sizeof($this->_postErrors)) {
                     $_thisLink = $_checkUpdate;
                     $_thisSlideIsChanged = true;
                 }
             }
             if ($_checkUpdate = Tools::getValue($this->name . '_order' . $_thisID)) {
                 $this->_numericValidation($_checkUpdate, 'order');
                 if (!sizeof($this->_postErrors)) {
                     $_thisOrder = $_checkUpdate;
                     $_thisSlideIsChanged = true;
                 }
             }
             if ($_checkUpdate = Tools::getValue($this->name . '_header' . $_thisID)) {
                 $_thisHeader = strip_tags(nl2br2($_checkUpdate));
                 $_thisSlideIsChanged = true;
             }
             if ($_checkUpdate = Tools::getValue($this->name . '_price' . $_thisID)) {
                 $_thisPrice = strip_tags(nl2br2($_checkUpdate));
                 $_thisSlideIsChanged = true;
             }
             if ($_checkUpdate = (int) Tools::getValue($this->name . '_active' . $_thisID)) {
                 if ($_checkUpdate == 1 && $_thisActive == 0) {
                     $_thisActive = 1;
                     $_thisSlideIsChanged = true;
                 }
             } elseif ((int) Tools::getValue($this->name . '_active' . $_thisID) != 1 && $_thisActive == 1) {
                 $_thisActive = 0;
                 $_thisSlideIsChanged = true;
             }
             if ($_thisSlideIsChanged == true) {
                 $this->_updataSlide($_thisID, $_thisLink, $_thisImageDir, $_thisHeader, $_thisPrice, $_thisOrder, $_thisActive);
             }
         }
         /* end foreach */
         if (!sizeof($this->_postErrors)) {
             $this->_html .= '<div class="conf confirm">' . $this->l('Ustawienia zostały zaktualizowane') . '</div>';
         } else {
             foreach ($this->_postErrors as $err) {
                 $this->_html .= '<div class="alert error">' . $err . '</div>';
             }
         }
     }
     /*end isSubmit('updateSlider'); */
     if (Tools::isSubmit('updateSettings')) {
         foreach ($this->kinkyslider_config as $configRowToUpdate) {
             if ($_checkUpdate = Tools::getValue($this->name . '_config_' . $configRowToUpdate['kinky_key'])) {
                 switch ($configRowToUpdate['kinky_validation']) {
                     case KINKYSLIDER_VALIDATION_STANDARD:
                         break;
                     case KINKYSLIDER_VALIDATION_NUMERIC:
                         $this->_numericValidation($_checkUpdate, $configRowToUpdate['sml_key']);
                         break;
                     case KINKYSLIDER_VALIDATION_NUMERIC_OR_NONE:
                         $this->_numericOrNoneValidation($_checkUpdate, $configRowToUpdate['kinky_label']);
                         break;
                     case KINKYSLIDER_VALIDATION_NUMERIC_OR_AUTO:
                         $this->_numericOrAutoValidation($_checkUpdate, $configRowToUpdate['kinky_label']);
                         break;
                 }
                 if (!sizeof($this->_postErrors)) {
                     $_thisNewValue = strip_tags(nl2br2($_checkUpdate));
                     $this->_setConfigValue($configRowToUpdate['kinky_id'], $_thisNewValue);
                 }
             } elseif (Tools::getValue($this->name . '_config_' . $configRowToUpdate['kinky_key']) == 0) {
                 $_thisNewValue = 0;
                 $this->_setConfigValue($configRowToUpdate['kinky_id'], $_thisNewValue);
             }
         }
         if (!sizeof($this->_postErrors)) {
             $this->_html .= '<div class="conf confirm">Your settings have been saved.</div>';
         } else {
             foreach ($this->_postErrors as $err) {
                 $this->_html .= '<div class="alert error">' . $err . '</div>';
             }
         }
     }
     $this->_getSettings();
     $this->_getSlideList();
     $this->_displayForm();
     return $this->_html;
 }
Ejemplo n.º 8
0
 private function _postProcessParameters()
 {
     // Saving new configurations
     if ($this->setConfiguration('EBAY_PAYPAL_EMAIL', pSQL(Tools::getValue('ebay_paypal_email'))) && $this->setConfiguration('EBAY_IDENTIFIER', pSQL(Tools::getValue('ebay_identifier'))) && $this->setConfiguration('EBAY_RETURNS_ACCEPTED_OPTION', pSQL(Tools::getValue('ebay_returns_accepted_option'))) && $this->setConfiguration('EBAY_RETURNS_DESCRIPTION', $this->isVersionOneDotFive() ? Tools::nl2br(Tools::getValue('ebay_returns_description')) : nl2br2(Tools::getValue('ebay_returns_description')), true) && $this->setConfiguration('EBAY_SHOP', pSQL(Tools::getValue('ebay_shop'))) && $this->setConfiguration('EBAY_SHOP_POSTALCODE', pSQL(Tools::getValue('ebay_shop_postalcode'))) && $this->setConfiguration('EBAY_LISTING_DURATION', Tools::getValue('listingdurations')) && $this->setConfiguration('EBAY_AUTOMATICALLY_RELIST', Tools::getValue('automaticallyrelist')) && $this->setConfiguration('EBAY_CONDITION_NEW', Tools::getValue('newConditionID')) && $this->setConfiguration('EBAY_CONDITION_USED', Tools::getValue('usedConditionID')) && $this->setConfiguration('EBAY_CONDITION_REFURBISHED', Tools::getValue('refurbishedConditionID'))) {
         $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
     } else {
         $this->_html .= $this->displayError($this->l('Settings failed'));
     }
 }
}
function process_answer($str)
{
    $str = trim($str);
    $f_str = preg_replace("/\\([A-Da-d]\\)/", "", substr($str, 0, 3)) . substr($str, 3);
    return html_entity_decode(trim($f_str));
}
function process_answer_option($str)
{
    $ansArray = array("1" => "A", "2" => "B", "3" => "C", "4" => "D");
    $str = trim($str);
    return array_search(substr($str, -1), $ansArray);
}
// Retrieve the DOM from a given URL
//$html = file_get_html('file:///var/www/html/quizmaster/upload/uk.html');
$html = nl2br2(file_get_contents('/var/www/html/quizmaster/upload/GKindiagktime.html'));
//echo $html;
$htmlArray = explode("<br />", $html);
$out = fopen('/var/www/html/quizmaster/upload/new.csv', 'w');
fputcsv($out, array('question', 'option_1', 'option_2', 'option_3', 'option_4', 'correct_answer', 'category', 'explanation', 'multi_answer'));
// Find all "span" tags and print their HREFs
$cnt = count($htmlArray);
$i = 0;
while ($i < $cnt) {
    $i = $i + 2;
    $data = array();
    $data['question'] = $htmlArray[$i++];
    $data['option_1'] = process_answer($htmlArray[$i++]);
    $data['option_2'] = process_answer($htmlArray[$i++]);
    $data['option_3'] = process_answer($htmlArray[$i++]);
    $data['option_4'] = process_answer($htmlArray[$i++]);
Ejemplo n.º 10
0
         /* Scenes  (could be externalised to another controler if you need them */
         $smarty->assign('scenes', Scene::getScenes(intval($category->id), intval($cookie->id_lang), true, false));
         /* Scenes images formats */
         if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) {
             foreach ($sceneImageTypes as $sceneImageType) {
                 if ($sceneImageType['name'] == 'thumb_scene') {
                     $thumbSceneImageType = $sceneImageType;
                 } elseif ($sceneImageType['name'] == 'large_scene') {
                     $largeSceneImageType = $sceneImageType;
                 }
             }
             $smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
             $smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
         }
         $category->name = Category::hideCategoryPosition($category->name);
         $category->description = nl2br2($category->description);
         $subCategories = $category->getSubCategories(intval($cookie->id_lang));
         $smarty->assign('category', $category);
         if (Db::getInstance()->numRows()) {
             $smarty->assign('subcategories', $subCategories);
         }
         if ($category->id != 1) {
             $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true);
             include dirname(__FILE__) . '/pagination.php';
             $smarty->assign('nb_products', $nbProducts);
             $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay);
         }
         $smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)), 'path' => Tools::getPath(intval($category->id), $category->name)));
     }
 }
 $smarty->assign(array('allow_oosp' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'suppliers' => Supplier::getSuppliers(), 'errors' => $errors));
Ejemplo n.º 11
0
 private function _postProcessParameters()
 {
     // Saving new configurations
     if ($this->setConfiguration('EBAY_PAYPAL_EMAIL', pSQL(Tools::getValue('ebay_paypal_email'))) && $this->setConfiguration('EBAY_IDENTIFIER', pSQL(Tools::getValue('ebay_identifier'))) && $this->setConfiguration('EBAY_RETURNS_ACCEPTED_OPTION', pSQL(Tools::getValue('ebay_returns_accepted_option'))) && $this->setConfiguration('EBAY_RETURNS_DESCRIPTION', version_compare(_PS_VERSION_, '1.5', '>') ? Tools::nl2br(Tools::getValue('ebay_returns_description')) : nl2br2(Tools::getValue('ebay_returns_description')), true) && $this->setConfiguration('EBAY_SHOP', pSQL(Tools::getValue('ebay_shop'))) && $this->setConfiguration('EBAY_SHOP_POSTALCODE', pSQL(Tools::getValue('ebay_shop_postalcode'))) && $this->setConfiguration('EBAY_LISTING_DURATION', Tools::getValue('listingdurations')) && $this->setConfiguration('EBAY_PICTURE_SIZE_DEFAULT', (int) Tools::getValue('sizedefault')) && $this->setConfiguration('EBAY_PICTURE_SIZE_SMALL', (int) Tools::getValue('sizesmall')) && $this->setConfiguration('EBAY_PICTURE_SIZE_BIG', (int) Tools::getValue('sizebig')) && $this->setConfiguration('EBAY_AUTOMATICALLY_RELIST', Tools::getValue('automaticallyrelist')) && $this->setConfiguration('EBAY_RETURNS_WITHIN', pSQL(Tools::getValue('returnswithin'))) && $this->setConfiguration('EBAY_RETURNS_WHO_PAYS', pSQL(Tools::getValue('returnswhopays')))) {
         $this->html .= $this->displayConfirmation($this->l('Settings updated'));
     } else {
         $this->html .= $this->displayError($this->l('Settings failed'));
     }
 }
Ejemplo n.º 12
0
    public function postProcess()
    {
        global $currentIndex, $cookie, $link;
        if ($id_customer_thread = (int) Tools::getValue('id_customer_thread')) {
            if ($id_contact = (int) Tools::getValue('id_contact')) {
                Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'customer_thread SET id_contact = ' . (int) $id_contact . ' WHERE id_customer_thread = ' . (int) $id_customer_thread);
            }
            if ($id_status = (int) Tools::getValue('setstatus')) {
                $statusArray = array(1 => 'open', 2 => 'closed', 3 => 'pending1', 4 => 'pending2');
                Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'customer_thread SET status = "' . $statusArray[$id_status] . '" WHERE id_customer_thread = ' . (int) $id_customer_thread . ' LIMIT 1');
            }
            if (isset($_POST['id_employee_forward'])) {
                // Todo: need to avoid doubles
                $messages = Db::getInstance()->ExecuteS('
				SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname
				FROM ' . _DB_PREFIX_ . 'customer_thread ct
				LEFT JOIN ' . _DB_PREFIX_ . 'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread)
				LEFT JOIN ' . _DB_PREFIX_ . 'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = ' . (int) $cookie->id_lang . ')
				LEFT OUTER JOIN ' . _DB_PREFIX_ . 'employee e ON e.id_employee = cm.id_employee
				LEFT OUTER JOIN ' . _DB_PREFIX_ . 'customer c ON (c.email = ct.email)
				WHERE ct.id_customer_thread = ' . (int) Tools::getValue('id_customer_thread') . '
				ORDER BY cm.date_add DESC');
                $output = '';
                foreach ($messages as $message) {
                    $output .= $this->displayMsg($message, true, (int) Tools::getValue('id_employee_forward'));
                }
                $cm = new CustomerMessage();
                $cm->id_employee = (int) $cookie->id_employee;
                $cm->id_customer_thread = (int) Tools::getValue('id_customer_thread');
                $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
                $currentEmployee = new Employee($cookie->id_employee);
                if ($id_employee = (int) Tools::getValue('id_employee_forward') and $employee = new Employee($id_employee) and Validate::isLoadedObject($employee)) {
                    $params = array('{messages}' => $output, '{employee}' => $currentEmployee->firstname . ' ' . $currentEmployee->lastname, '{comment}' => stripslashes($_POST['message_forward']));
                    if (Mail::Send((int) $cookie->id_lang, 'forward_msg', Mail::l('Fwd: Customer message', (int) $cookie->id_lang), $params, $employee->email, $employee->firstname . ' ' . $employee->lastname, $currentEmployee->email, $currentEmployee->firstname . ' ' . $currentEmployee->lastname, NULL, NULL, _PS_MAIL_DIR_, true)) {
                        $cm->message = $this->l('Message forwarded to') . ' ' . $employee->firstname . ' ' . $employee->lastname . "\n" . $this->l('Comment:') . ' ' . $_POST['message_forward'];
                        $cm->add();
                    }
                } elseif ($email = Tools::getValue('email') and Validate::isEmail($email)) {
                    $params = array('{messages}' => $output, '{employee}' => $currentEmployee->firstname . ' ' . $currentEmployee->lastname, '{comment}' => stripslashes($_POST['message_forward']));
                    if (Mail::Send((int) $cookie->id_lang, 'forward_msg', Mail::l('Fwd: Customer message', (int) $cookie->id_lang), $params, $email, NULL, $currentEmployee->email, $currentEmployee->firstname . ' ' . $currentEmployee->lastname, NULL, NULL, _PS_MAIL_DIR_, true)) {
                        $cm->message = $this->l('Message forwarded to') . ' ' . $email . "\n" . $this->l('Comment:') . ' ' . $_POST['message_forward'];
                        $cm->add();
                    }
                } else {
                    echo '<div class="alert error">' . Tools::displayError('Email invalid.') . '</div>';
                }
            }
            if (Tools::isSubmit('submitReply')) {
                $ct = new CustomerThread($id_customer_thread);
                $cm = new CustomerMessage();
                $cm->id_employee = (int) $cookie->id_employee;
                $cm->id_customer_thread = $ct->id;
                $cm->message = Tools::htmlentitiesutf8(nl2br2(Tools::getValue('reply_message')));
                $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
                if (isset($_FILES) and !empty($_FILES['joinFile']['name']) and $_FILES['joinFile']['error'] != 0) {
                    $this->_errors[] = Tools::displayError('An error occurred with the file upload.');
                } elseif ($cm->add()) {
                    $fileAttachment = NULL;
                    if (!empty($_FILES['joinFile']['name'])) {
                        $fileAttachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']);
                        $fileAttachment['name'] = $_FILES['joinFile']['name'];
                        $fileAttachment['mime'] = $_FILES['joinFile']['type'];
                    }
                    $params = array('{reply}' => nl2br2(Tools::getValue('reply_message')), '{link}' => $link->getPageLink('contact-form.php', true) . '?id_customer_thread=' . (int) $ct->id . '&token=' . $ct->token);
                    if (Mail::Send((int) $ct->id_lang, 'reply_msg', Mail::l('An answer to your message is available', (int) $ct->id_lang), $params, Tools::getValue('msg_email'), NULL, NULL, NULL, $fileAttachment, NULL, _PS_MAIL_DIR_, true)) {
                        $ct->status = 'closed';
                        $ct->update();
                    }
                    Tools::redirectAdmin($currentIndex . '&id_customer_thread=' . (int) $id_customer_thread . '&viewcustomer_thread&token=' . Tools::getValue('token'));
                } else {
                    $this->_errors[] = Tools::displayError('An error occurred, your message was not sent. Please contact your system administrator.');
                }
            }
        }
        return parent::postProcess();
    }
Ejemplo n.º 13
0
 public function hookPaymentReturn($params)
 {
     if (!$this->active) {
         return;
     }
     global $smarty;
     $state = $params['objOrder']->getCurrentState();
     if ($state == _PS_OS_BANKWIRE_ or $state == _PS_OS_OUTOFSTOCK_) {
         $smarty->assign(array('total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false, false), 'bankwireDetails' => nl2br2($this->details), 'bankwireAddress' => nl2br2($this->address), 'bankwireOwner' => $this->owner, 'status' => 'ok', 'id_order' => $params['objOrder']->id));
     } else {
         $smarty->assign('status', 'failed');
     }
     return $this->display(__FILE__, 'payment_return.tpl');
 }
Ejemplo n.º 14
0
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<input type="hidden" name="id_order" value="' . $obj->id_order . '" />
			<input type="hidden" name="id_customer" value="' . $obj->id_customer . '" />
			<fieldset><legend><img src="../img/admin/return.gif" />' . $this->l('Return Merchandise Authorization (RMA)') . '</legend>
				<label>' . $this->l('Customer:') . ' </label>';
        $customer = new Customer((int) $obj->id_customer);
        echo '
				<div class="margin-form">' . $customer->firstname . ' ' . $customer->lastname . '
				<p style="clear: both"><a href="index.php?tab=AdminCustomers&id_customer=' . $customer->id . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '">' . $this->l('View details on customer page') . '</a></p>
				</div>
				<label>' . $this->l('Order:') . ' </label>';
        $order = new Order((int) $obj->id_order);
        echo '		<div class="margin-form">' . $this->l('Order #') . sprintf('%06d', $order->id) . ' ' . $this->l('from') . ' ' . Tools::displayDate($order->date_upd, $order->id_lang) . '
				<p style="clear: both"><a href="index.php?tab=AdminOrders&id_order=' . $order->id . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee) . '">' . $this->l('View details on order page') . '</a></p>
				</div>
				<label>' . $this->l('Customer explanation:') . ' </label>
				<div class="margin-form">' . nl2br2($obj->question) . '</div>

				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
				<select name=\'state\'>';
        $states = OrderReturnState::getOrderReturnStates($cookie->id_lang);
        foreach ($states as $state) {
            echo '<option value="' . $state['id_order_return_state'] . '"' . ($obj->state == $state['id_order_return_state'] ? ' selected="selected"' : '') . '>' . $state['name'] . '</option>';
        }
        echo '	</select>
				<p style="clear: both">' . $this->l('Merchandise return (RMA) status') . '</p>
				</div>';
        if ($obj->state >= 3) {
            echo '	<label>' . $this->l('Slip:') . ' </label>
				<div class="margin-form">' . $this->l('Generate a new slip from the customer order') . '
				<p style="clear: both"><a href="index.php?tab=AdminOrders&id_order=' . $order->id . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee) . '#products">' . $this->l('More information on order page') . '</a></p>
				</div>';
        }
        echo '	<label>' . $this->l('Products:') . ' </label>
				<div class="margin-form">';
        echo '<table cellpadding="0" cellspacing="0">
					<tr>
						<td class="col-left">&nbsp;</td>
						<td>
							<table cellspacing="0" cellpadding="0" class="table">
							<tr>
								<th style="width: 100px;">' . $this->l('Reference') . '</th>
								<th>' . $this->l('Product name') . '</th>
								<th>' . $this->l('Quantity') . '</th>
								<th>' . $this->l('Action') . '</th>
							</tr>';
        $order = new Order((int) $obj->id_order);
        $quantityDisplayed = array();
        /* Customized products */
        if ($returnedCustomizations = OrderReturn::getReturnedCustomizedProducts((int) $obj->id_order)) {
            $allCustomizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
            foreach ($returnedCustomizations as $returnedCustomization) {
                echo '
					<tr>
						<td>' . $returnedCustomization['reference'] . '</td>
						<td class="center">' . $returnedCustomization['name'] . '</td>
						<td class="center">' . (int) $returnedCustomization['product_quantity'] . '</td>
						<td class="center"><a href="' . $currentIndex . '&deleteorder_return_detail&id_order_detail=' . $returnedCustomization['id_order_detail'] . '&id_customization=' . $returnedCustomization['id_customization'] . '&id_order_return=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/delete.gif"></a></td>
					</tr>';
                $customizationDatas =& $allCustomizedDatas[(int) $returnedCustomization['product_id']][(int) $returnedCustomization['product_attribute_id']][(int) $returnedCustomization['id_customization']]['datas'];
                foreach ($customizationDatas as $type => $datas) {
                    echo '<tr>
						<td colspan="4">';
                    if ($type == _CUSTOMIZE_FILE_) {
                        $i = 0;
                        echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
                        foreach ($datas as $data) {
                            echo '<li style="display: inline; margin: 2px;">
										<a href="displayImage.php?img=' . $data['value'] . '&name=' . (int) $order->id . '-file' . ++$i . '" target="_blank"><img src="' . _THEME_PROD_PIC_DIR_ . $data['value'] . '_small" alt="" /></a>
									</li>';
                        }
                        echo '</ul>';
                    } elseif ($type == _CUSTOMIZE_TEXTFIELD_) {
                        $i = 0;
                        echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
                        foreach ($datas as $data) {
                            echo '<li>' . ($data['name'] ? $data['name'] : $this->l('Text #') . ++$i) . $this->l(':') . ' ' . $data['value'] . '</li>';
                        }
                        echo '</ul>';
                    }
                    echo '</td>
						</tr>';
                }
                $quantityDisplayed[(int) $returnedCustomization['id_order_detail']] = isset($quantityDisplayed[(int) $returnedCustomization['id_order_detail']]) ? $quantityDisplayed[(int) $returnedCustomization['id_order_detail']] + (int) $returnedCustomization['product_quantity'] : (int) $returnedCustomization['product_quantity'];
            }
        }
        /* Classic products */
        $products = OrderReturn::getOrdersReturnProducts($obj->id, $order);
        foreach ($products as $k => $product) {
            if (!isset($quantityDisplayed[(int) $product['id_order_detail']]) or (int) $product['product_quantity'] > (int) $quantityDisplayed[(int) $product['id_order_detail']]) {
                echo '
					<tr>
						<td>' . $product['product_reference'] . '</td>
						<td class="center">' . $product['product_name'] . '</td>
						<td class="center">' . $product['product_quantity'] . '</td>
						<td class="center"><a href="' . $currentIndex . '&deleteorder_return_detail&id_order_detail=' . $product['id_order_detail'] . '&id_order_return=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/delete.gif"></a></td>
					</tr>';
            }
        }
        echo '
							</table>
						</td>
					</tr>
				</table>
				<p>' . $this->l('List of products in return package') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" style="margin-right:120px;"/>
				</div>
			</fieldset>
		</form>';
    }
Ejemplo n.º 15
0
 function amr_format_value($content, $k, $event, $before = '', $after = '')
 {
     /* include the event so we can check for things like all day */
     /*  Format each Ical value for our presentation purposes
     	Note: Google does toss away the html when editing the text, but it is there if you add but don't edit.
     	what about all day?
     	*/
     global $amr_formats;
     /* amr check that this get set to the chosen list type */
     global $amr_options;
     global $amr_listtype;
     global $eventtaxonomies;
     //	echo '<br >'.$k;
     if (empty($content)) {
         return '';
     }
     if ($k == 'ORGANIZER') {
         // it is an array but a parsed one, not repeatable
         $htmlcontent = amr_format_organiser($content);
     } elseif ($k == 'ATTENDEE') {
         // it is an array but a parsed one, not repeatable
         $htmlcontent = amr_format_attendees($content);
     } elseif ($k == 'Attendee-counts') {
         // it is an array but we format the whole thing once
         $htmlcontent = amr_format_attendee_counts($content);
     } else {
         if (is_object($content)) {
             switch ($k) {
                 case 'EventDate':
                     $htmlcontent = '<abbr class="dtstart" title="' . amr_format_date('c', $content) . '">' . amr_format_date($amr_formats['Day'], $content) . '</abbr>';
                     break;
                 case 'EndDate':
                     $days = amr_event_is_multiday($event);
                     if ($days > 1) {
                         $htmlcontent = '<abbr class="dtend" title="' . amr_format_date('c', $content) . '">' . amr_format_date($amr_formats['Day'], $content) . '</abbr>';
                     } else {
                         $htmlcontent = '';
                     }
                     break;
                 case 'EndTime':
                 case 'StartTime':
                     if (isset($event['allday']) and $event['allday'] === 'allday') {
                         $htmlcontent = '';
                     } else {
                         $htmlcontent = amr_format_time($amr_formats['Time'], $content);
                     }
                     break;
                 case 'DTSTART':
                 case 'DTEND':
                 case 'UNTIL':
                     $htmlcontent = amr_format_date($amr_formats['Day'], $content);
                     if (empty($event['allday']) or !($event['allday'] == 'allday')) {
                         $htmlcontent .= ' ' . amr_format_time($amr_formats['Time'], $content);
                     }
                     break;
                 case 'X-WR-TIMEZONE':
                     /* amr  need to add code to reformat the timezone as per admin entry.  Also only show if timezone different ? */
                     $htmlcontent = amr_format_tz(timezone_name_get($content));
                     break;
                 case 'TZID':
                     /* amr  need to add code to reformat the timezone as per admin entry.  Also only show if timezone different ? */
                     $htmlcontent = amr_format_tz(timezone_name_get($content));
                     break;
                 case 'timezone':
                     /* amr  need to add code to reformat the timezone as per admin entry.  Also only show if timezone different ? */
                     $htmlcontent = amr_format_timezone($content);
                     break;
                 default:
                     /* should not be any */
                     $htmlcontent = amr_format_date($amr_formats['DateTime'], $content);
             }
         } elseif (is_array($content)) {
             if ($k === 'DURATION') {
                 $htmlcontent = amr_format_duration($content);
             } elseif ($k === 'RRULE' or $k === 'EXRULE') {
                 $htmlcontent = amr_format_rrule($content);
             } elseif ($k === 'RDATE' or $k === 'EXDATE') {
                 $htmlcontent = amr_prettyprint_r_ex_date($content);
             } elseif ($k === 'CATEGORIES') {
                 // umm - what if ics category
                 $htmlcontent = amr_format_taxonomies('category', $content);
             } elseif ($k === 'post_tag') {
                 $htmlcontent = amr_format_taxonomies('post_tag', $content);
             } elseif ($k == 'ATTACH') {
                 if (isset($content[0]['type'])) {
                     // then we are at the top level of the array, so can ask to handled repetaed values
                     return amr_format_repeatable_property($content, $k, $event, $before, $after);
                 } else {
                     $htmlcontent = amr_format_attach($content, $event);
                 }
             } else {
                 /* simple array don't think we need to list the items separately eg: multiple comments or descriptions - just line  */
                 if (!empty($eventtaxonomies) and in_array($k, $eventtaxonomies)) {
                     $htmlcontent = amr_format_taxonomies($k, $content);
                 } else {
                     return amr_format_repeatable_property($content, $k, $event, $before, $after);
                 }
             }
         } elseif (is_null($content) or $content === '') {
             $htmlcontent = '';
         } else {
             if (function_exists('amr_format_' . $k)) {
                 $htmlcontent = call_user_func('amr_format_' . $k, $content);
             } else {
                 switch ($k) {
                     case 'COMMENT':
                     case 'DESCRIPTION':
                         //var_dump($content);
                         $htmlcontent = html_entity_decode(amr_click_and_trim(nl2br2(amr_amp($content))));
                         break;
                     case 'SUMMARY':
                     case 'icsurl':
                     case 'addtogoogle':
                     case 'addevent':
                     case 'subscribeevent':
                     case 'subscribeseries':
                     case 'map':
                     case 'refresh':
                     case 'attending_event':
                         $htmlcontent = $content;
                         /* avoid hyperlink as we may have added url already */
                         break;
                     case 'URL':
                         /* assume valid URL, should not need to validate here, then format it as such */
                         $htmlcontent = amr_format_url($content);
                         break;
                     case 'LOCATION':
                         $htmlcontent = amr_click_and_trim(nl2br2(amr_amp($content)));
                         break;
                     case 'X-WR-TIMEZONE':
                         /* not parsed as object - since it is cal attribute, not property attribue */
                         $htmlcontent = amr_format_tz($content);
                         break;
                     case 'allday':
                         $htmlcontent = amr_format_allday($content);
                         break;
                     default:
                         /* Convert any newlines to html breaks */
                         if (!empty($eventtaxonomies) and in_array($k, $eventtaxonomies)) {
                             $htmlcontent = amr_format_taxonomies($k, $content);
                         } else {
                             $func = 'amr_format_' . str_replace('-', '_', $k);
                             if (function_exists($func)) {
                                 $htmlcontent = call_user_func($func, $content);
                             }
                             $htmlcontent = str_replace("\n", "<br />", $content);
                         }
                 }
             }
         }
     }
     if (empty($htmlcontent)) {
         return;
     }
     return $before . $htmlcontent . $after;
 }
Ejemplo n.º 16
0
    private function _displayConfiguration()
    {
        global $cookie;
        $this->_html .= '<script type="text/javascript">
									$(document).ready(function() {
										$(\'#submitCreateAccount\').unbind(\'click\').click(function() {
										if (!$(\'#terms_and_conditions\').attr(\'checked\'))
										{
											alert(\'' . $this->l('Please accept the terms of service.') . '\');
											return false;
										}
									});										
									});
								</script>
		<fieldset><legend>' . $this->l('PrestaShop Security configuration') . '</legend>
			<div id="choose_account">
				<center>
				<form>
					<input type="radio" ' . (!Configuration::get('PS_TRUST_SHOP_ID') ? 'checked="checked"' : '') . ' onclick="$(\'#create_account\').show(); $(\'#module_configuration\').hide();" id="trust_account_on" name="trust_account" value="0"/> <b>' . $this->l('My shop does not have a PrestaShop Security account yet') . '</b>&nbsp;&nbsp;&nbsp;
					<input type="radio" ' . (Configuration::get('PS_TRUST_SHOP_ID') ? 'checked="checked"' : '') . ' onclick="$(\'#create_account\').hide(); $(\'#module_configuration\').show();"  id="trust_account_off" name="trust_account" value="1" /> <b>' . $this->l('I already have an account') . '</b>
				</form>
				</center>
			</div>
			<div class="clear">&nbsp;</div>
			<div id="create_account" ' . (Configuration::get('PS_TRUST_SHOP_ID') ? 'style="display:none;"' : '') . '>
				<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post" name="prestashop_trust" id="prestashop_trust">
					<label>' . $this->l('Your email:') . '</label>
					<div class="margin-form">
						<input type="text" style="width:200px;" name="email" />
					</div>
					<label>' . $this->l('Shop Url:') . '</label>
					<div class="margin-form">
						<input type="text" style="width:400px;" name="shop_url" value="http://www.' . Tools::getHttpHost() . __PS_BASE_URI__ . '"/>
					</div>
					<div class="margin-form">
						<input id="terms_and_conditions" type="checkbox" value="1" /> ' . $this->l('I agree with the terms of PrestaShop Security service and I adhere to them unconditionally.') . '</label>
					</div>
					<div id="terms" class="margin-form">';
        $terms = file_get_contents($this->_trustUrl . 'terms.php?lang=' . Language::getIsoById((int) $cookie->id_lang));
        $this->_html .= '<div style="height:300px;border:1px solid #E0D0B1;overflow-y:scroll;padding:8px;color:black">' . nl2br2(strip_tags($terms)) . '</div>';
        $this->_html .= '</div>
					<div class="margin-form">
						<input class="button" type="submit" id="submitCreateAccount" name="submitCreateAccount" value="' . $this->l('Create account') . '"/>
					</div>
				</form>
				<div class="clear">&nbsp;</div>
			</div>
			<div id="module_configuration" ' . (!Configuration::get('PS_TRUST_SHOP_ID') ? 'style="display:none;"' : '') . '>
			<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post" name="prestashop_trust" id="prestashop_trust">
				<label>' . $this->l('Shop ID:') . '</label>
				<div class="margin-form">
					<input type="text" style="width:150px"  name="shop_id" value="' . Configuration::get('PS_TRUST_SHOP_ID') . '"/>
				</div>
				<label>' . $this->l('Shop KEY:') . '</label>
				<div class="margin-form">
					<input type="text" style="width:300px" name="shop_key" value="' . Configuration::get('PS_TRUST_SHOP_KEY') . '"/>
				</div>
				<div class="clear">&nbsp;</div>
				<label>' . $this->l('Shop activity:') . '
				<div class="margin-form">
					<select name="shop_activity">';
        foreach ($this->_activities as $k => $activity) {
            $this->_html .= '<option value="' . $k . '" ' . ($k == Configuration::get('PS_SHOP_ACTIVITY') ? 'selected="selected"' : '') . '>' . $activity . '</option>';
        }
        $this->_html .= '</select>
				</div>';
        $carriers = Carrier::getCarriers((int) $cookie->id_lang, true);
        $trust_carriers_type = $this->_getPrestaTrustCarriersType();
        $configured_carriers = $this->_getConfiguredCarriers();
        $this->_html .= '
				<label>' . $this->l('Carriers:') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Carrier') . '</th><th>' . $this->l('Carrier Type') . '</th></tr></thead><tbody>';
        foreach ($carriers as $carrier) {
            $this->_html .= '<tr><td>' . $carrier['name'] . '</td><td><select name="carrier_' . $carrier['id_carrier'] . '">
			<option value="0">' . $this->l('Choose a carrier type...') . '</option>';
            foreach ($this->_getPrestaTrustCarriersType() as $type => $name) {
                $this->_html .= '<option value="' . $type . '"' . ((isset($configured_carriers[$carrier['id_carrier']]) and $type == $configured_carriers[$carrier['id_carrier']]) ? ' selected="selected"' : '') . '>' . $name . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>';
        $modules = PaymentModule::getInstalledPaymentModules();
        $configured_payments = $this->_getConfiguredPayments();
        $this->_html .= '
				<label>' . $this->l('Payments:') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Payment Module') . '</th><th>' . $this->l('Payment Type') . '</th></tr></thead><tbody>';
        foreach ($modules as $module) {
            $mod = Module::getInstanceByName($module['name']);
            $this->_html .= '<tr><td>' . $mod->displayName . '</td><td><select name="paymentmodule_' . $mod->id . '">
			<option value="0">' . $this->l('Choose a payment type...') . '</option>';
            foreach ($this->_payment_types as $type => $name) {
                $this->_html .= '<option value="' . $type . '"' . ((isset($configured_payments[$mod->id]) and $type == $configured_payments[$mod->id]) ? ' selected="true"' : '') . '>' . $name . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>';
        $this->_html .= '<center><input type="submit" name="submitSettings" value="' . $this->l('Save') . '" class="button" /></center>
		</form>
		</div>
		</fieldset>';
        return $this->_html;
    }
Ejemplo n.º 17
0
    public function viewDetails()
    {
        global $currentIndex, $cookie, $link;
        $irow = 0;
        if (!($order = $this->loadObject())) {
            return;
        }
        $customer = new Customer($order->id_customer);
        $customerStats = $customer->getStats();
        $addressInvoice = new Address($order->id_address_invoice, (int) $cookie->id_lang);
        if (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) {
            $invoiceState = new State((int) $addressInvoice->id_state);
        }
        $addressDelivery = new Address($order->id_address_delivery, (int) $cookie->id_lang);
        if (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) {
            $deliveryState = new State((int) $addressDelivery->id_state);
        }
        $carrier = new Carrier($order->id_carrier);
        $history = $order->getHistory($cookie->id_lang);
        $products = $order->getProducts();
        $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
        Product::addCustomizationPrice($products, $customizedDatas);
        $discounts = $order->getDiscounts();
        $messages = Message::getMessagesByOrderId($order->id, true);
        $states = OrderState::getOrderStates((int) $cookie->id_lang);
        $currency = new Currency($order->id_currency);
        $currentLanguage = new Language((int) $cookie->id_lang);
        $currentState = OrderHistory::getLastOrderState($order->id);
        $sources = ConnectionsSource::getOrderSources($order->id);
        $cart = Cart::getCartByOrderId($order->id);
        $row = array_shift($history);
        if ($prevOrder = Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_order < ' . (int) $order->id . ' ORDER BY id_order DESC')) {
            $prevOrder = '<a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&vieworder&id_order=' . $prevOrder . '"><img style="width:24px;height:24px" src="../img/admin/arrow-left.png" /></a>';
        }
        if ($nextOrder = Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_order > ' . (int) $order->id . ' ORDER BY id_order ASC')) {
            $nextOrder = '<a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&vieworder&id_order=' . $nextOrder . '"><img style="width:24px;height:24px" src="../img/admin/arrow-right.png" /></a>';
        }
        if ($order->total_paid != $order->total_paid_real) {
            echo '<center><span class="warning" style="font-size: 16px">' . $this->l('Warning:') . ' ' . Tools::displayPrice($order->total_paid_real, $currency, false) . ' ' . $this->l('paid instead of') . ' ' . Tools::displayPrice($order->total_paid, $currency, false) . ' !</span></center><div class="clear"><br /><br /></div>';
        }
        // display bar code if module enabled
        $hook = Module::hookExec('invoice', array('id_order' => $order->id));
        if ($hook !== false) {
            echo '<div style="float: right; margin: -40px 40px 10px 0;">';
            echo $hook;
            echo '</div><br class="clear" />';
        }
        // display order header
        echo '
		<div style="float:left" style="width:440px">';
        echo '<h2>
				' . $prevOrder . '
				' . (Validate::isLoadedObject($customer) ? $customer->firstname . ' ' . $customer->lastname . ' - ' : '') . $this->l('Order #') . sprintf('%06d', $order->id) . '
				' . $nextOrder . '
			</h2>
			<div style="width:429px">
				' . ((($currentState->invoice or $order->invoice_number) and count($products)) ? '<a href="pdf.php?id_order=' . $order->id . '&pdf"><img src="../img/admin/charged_ok.gif" alt="' . $this->l('View invoice') . '" /> ' . $this->l('View invoice') . '</a>' : '<img src="../img/admin/charged_ko.gif" alt="' . $this->l('No invoice') . '" /> ' . $this->l('No invoice')) . ' -
				' . (($currentState->delivery or $order->delivery_number) ? '<a href="pdf.php?id_delivery=' . $order->delivery_number . '"><img src="../img/admin/delivery.gif" alt="' . $this->l('View delivery slip') . '" /> ' . $this->l('View delivery slip') . '</a>' : '<img src="../img/admin/delivery_ko.gif" alt="' . $this->l('No delivery slip') . '" /> ' . $this->l('No delivery slip')) . ' -
				<a href="javascript:window.print()"><img src="../img/admin/printer.gif" alt="' . $this->l('Print order') . '" title="' . $this->l('Print order') . '" /> ' . $this->l('Print page') . '</a>
			</div>
			<div class="clear">&nbsp;</div>';
        /* Display current status */
        echo '
			<table cellspacing="0" cellpadding="0" class="table" style="width: 429px">
				<tr>
					<th>' . Tools::displayDate($row['date_add'], (int) $cookie->id_lang, true) . '</th>
					<th><img src="../img/os/' . $row['id_order_state'] . '.gif" /></th>
					<th>' . stripslashes($row['ostate_name']) . '</th>
					<th>' . (!empty($row['employee_lastname']) ? '(' . stripslashes(Tools::substr($row['employee_firstname'], 0, 1)) . '. ' . stripslashes($row['employee_lastname']) . ')' : '') . '</th>
				</tr>';
        /* Display previous status */
        foreach ($history as $row) {
            echo '
				<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
					<td>' . Tools::displayDate($row['date_add'], (int) $cookie->id_lang, true) . '</td>
					<td><img src="../img/os/' . $row['id_order_state'] . '.gif" /></td>
					<td>' . stripslashes($row['ostate_name']) . '</td>
					<td>' . (!empty($row['employee_lastname']) ? '(' . stripslashes(Tools::substr($row['employee_firstname'], 0, 1)) . '. ' . stripslashes($row['employee_lastname']) . ')' : '') . '</td>
				</tr>';
        }
        echo '
			</table>
			<br />';
        /* Display status form */
        echo '
			<form action="' . $currentIndex . '&view' . $this->table . '&token=' . $this->token . '" method="post" style="text-align:center;">
				<select name="id_order_state">';
        $currentStateTab = $order->getCurrentStateFull($cookie->id_lang);
        foreach ($states as $state) {
            echo '<option value="' . $state['id_order_state'] . '"' . ($state['id_order_state'] == $currentStateTab['id_order_state'] ? ' selected="selected"' : '') . '>' . stripslashes($state['name']) . '</option>';
        }
        echo '
				</select>
				<input type="hidden" name="id_order" value="' . $order->id . '" />
				<input type="submit" name="submitState" value="' . $this->l('Change') . '" class="button" />
			</form>';
        /* Display customer information */
        if (Validate::isLoadedObject($customer)) {
            echo '<br />
			<fieldset style="width: 400px">
				<legend><img src="../img/admin/tab-customers.gif" /> ' . $this->l('Customer information') . '</legend>
				<span style="font-weight: bold; font-size: 14px;"><a href="?tab=AdminCustomers&id_customer=' . $customer->id . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> ' . $customer->firstname . ' ' . $customer->lastname . '</a></span> (' . $this->l('#') . $customer->id . ')<br />
				(<a href="mailto:' . $customer->email . '">' . $customer->email . '</a>)<br /><br />';
            if ($customer->isGuest()) {
                echo '
				' . $this->l('This order has been placed by a') . ' <b>' . $this->l('guest') . '</b>';
                if (!Customer::customerExists($customer->email)) {
                    echo '<form method="POST" action="index.php?tab=AdminCustomers&id_customer=' . (int) $customer->id . '&token=' . Tools::getAdminTokenLite('AdminCustomers') . '">
						<input type="hidden" name="id_lang" value="' . (int) $order->id_lang . '" />
						<p class="center"><input class="button" type="submit" name="submitGuestToCustomer" value="' . $this->l('Transform to customer') . '" /></p>
						' . $this->l('This feature will generate a random password and send an e-mail to the customer') . '
					</form>';
                } else {
                    echo '<div><b style="color:red;">' . $this->l('A registered customer account exists with the same email address') . '</b></div>';
                }
            } else {
                echo $this->l('Account registered:') . ' ' . Tools::displayDate($customer->date_add, (int) $cookie->id_lang, true) . '<br />
				' . $this->l('Valid orders placed:') . ' <b>' . $customerStats['nb_orders'] . '</b><br />
				' . $this->l('Total paid since registration:') . ' <b>' . Tools::displayPrice(Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2), $currency, false) . '</b><br />';
            }
            echo '</fieldset>';
        }
        /* Display sources */
        if (sizeof($sources)) {
            echo '<br />
			<fieldset style="width: 400px;"><legend><img src="../img/admin/tab-stats.gif" /> ' . $this->l('Sources') . '</legend><ul ' . (sizeof($sources) > 3 ? 'style="height: 200px; overflow-y: scroll; width: 360px;"' : '') . '>';
            foreach ($sources as $source) {
                echo '<li>
						' . Tools::displayDate($source['date_add'], (int) $cookie->id_lang, true) . '<br />
						<b>' . $this->l('From:') . '</b> <a href="' . $source['http_referer'] . '">' . preg_replace('/^www./', '', parse_url($source['http_referer'], PHP_URL_HOST)) . '</a><br />
						<b>' . $this->l('To:') . '</b> ' . $source['request_uri'] . '<br />
						' . ($source['keywords'] ? '<b>' . $this->l('Keywords:') . '</b> ' . $source['keywords'] . '<br />' : '') . '<br />
					</li>';
            }
            echo '</ul></fieldset>';
        }
        // display hook specified to this page : AdminOrder
        if (($hook = Module::hookExec('adminOrder', array('id_order' => $order->id))) !== false) {
            echo $hook;
        }
        echo '
		</div>
		<div style="float: left; margin-left: 40px">';
        /* Display invoice information */
        echo '<fieldset style="width: 400px">';
        if (($currentState->invoice or $order->invoice_number) and count($products)) {
            echo '<legend><a href="pdf.php?id_order=' . $order->id . '&pdf"><img src="../img/admin/charged_ok.gif" /> ' . $this->l('Invoice') . '</a></legend>
				<a href="pdf.php?id_order=' . $order->id . '&pdf">' . $this->l('Invoice #') . '<b>' . Configuration::get('PS_INVOICE_PREFIX', (int) $cookie->id_lang) . sprintf('%06d', $order->invoice_number) . '</b></a>
				<br />' . $this->l('Created on:') . ' ' . Tools::displayDate($order->invoice_date, (int) $cookie->id_lang, true);
        } else {
            echo '<legend><img src="../img/admin/charged_ko.gif" />' . $this->l('Invoice') . '</legend>
				' . $this->l('No invoice yet.');
        }
        echo '</fieldset><br />';
        /* Display shipping infos */
        echo '
		<fieldset style="width:400px">
			<legend><img src="../img/admin/delivery.gif" /> ' . $this->l('Shipping information') . '</legend>
			' . $this->l('Total weight:') . ' <b>' . number_format($order->getTotalWeight(), 3) . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</b><br />
			' . $this->l('Carrier:') . ' <b>' . ($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name) . '</b><br />
			' . (($currentState->delivery or $order->delivery_number) ? '<br /><a href="pdf.php?id_delivery=' . $order->delivery_number . '">' . $this->l('Delivery slip #') . '<b>' . Configuration::get('PS_DELIVERY_PREFIX', (int) $cookie->id_lang) . sprintf('%06d', $order->delivery_number) . '</b></a><br />' : '');
        if ($order->shipping_number) {
            echo $this->l('Tracking number:') . ' <b>' . $order->shipping_number . '</b> ' . (!empty($carrier->url) ? '(<a href="' . str_replace('@', $order->shipping_number, $carrier->url) . '" target="_blank">' . $this->l('Track the shipment') . '</a>)' : '');
        }
        /* Carrier module */
        if ($carrier->is_module == 1) {
            $module = Module::getInstanceByName($carrier->external_module_name);
            if (method_exists($module, 'displayInfoByCart')) {
                echo call_user_func(array($module, 'displayInfoByCart'), $order->id_cart);
            }
        }
        /* Display shipping number field */
        if ($carrier->url && $order->hasBeenShipped()) {
            echo '
				<form action="' . $currentIndex . '&view' . $this->table . '&token=' . $this->token . '" method="post" style="margin-top:10px;">
					<input type="text" name="shipping_number" value="' . $order->shipping_number . '" />
					<input type="hidden" name="id_order" value="' . $order->id . '" />
					<input type="submit" name="submitShippingNumber" value="' . $this->l('Set shipping number') . '" class="button" />
				</form>';
        }
        echo '
		</fieldset>';
        /* Display summary order */
        echo '
		<br />
		<fieldset style="width: 400px">
			<legend><img src="../img/admin/details.gif" /> ' . $this->l('Order details') . '</legend>
			<label>' . $this->l('Original cart:') . ' </label>
			<div style="margin: 2px 0 1em 190px;"><a href="?tab=AdminCarts&id_cart=' . $cart->id . '&viewcart&token=' . Tools::getAdminToken('AdminCarts' . (int) Tab::getIdFromClassName('AdminCarts') . (int) $cookie->id_employee) . '">' . $this->l('Cart #') . sprintf('%06d', $cart->id) . '</a></div>
			<label>' . $this->l('Payment mode:') . ' </label>
			<div style="margin: 2px 0 1em 190px;">' . Tools::substr($order->payment, 0, 32) . ' ' . ($order->module ? '(' . $order->module . ')' : '') . '</div>
			<div style="margin: 2px 0 1em 50px;">
				<table class="table" width="300px;" cellspacing="0" cellpadding="0">
					<tr><td width="150px;">' . $this->l('Products') . '</td><td align="right">' . Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false) . '</td></tr>
					' . ($order->total_discounts > 0 ? '<tr><td>' . $this->l('Discounts') . '</td><td align="right">-' . Tools::displayPrice($order->total_discounts, $currency, false) . '</td></tr>' : '') . '
					' . ($order->total_wrapping > 0 ? '<tr><td>' . $this->l('Wrapping') . '</td><td align="right">' . Tools::displayPrice($order->total_wrapping, $currency, false) . '</td></tr>' : '') . '
					<tr><td>' . $this->l('Shipping') . '</td><td align="right">' . Tools::displayPrice($order->total_shipping, $currency, false) . '</td></tr>
					<tr style="font-size: 20px"><td>' . $this->l('Total') . '</td><td align="right">' . Tools::displayPrice($order->total_paid, $currency, false) . ($order->total_paid != $order->total_paid_real ? '<br /><font color="red">(' . $this->l('Paid:') . ' ' . Tools::displayPrice($order->total_paid_real, $currency, false, false) . ')</font>' : '') . '</td></tr>
				</table>
			</div>
			<div style="float: left; margin-right: 10px; margin-left: 42px;">
				<span class="bold">' . $this->l('Recycled package:') . '</span>
				' . ($order->recyclable ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />') . '
			</div>
			<div style="float: left; margin-right: 10px;">
				<span class="bold">' . $this->l('Gift wrapping:') . '</span>
				 ' . ($order->gift ? '<img src="../img/admin/enabled.gif" />
			</div>
			<div style="clear: left; margin: 0px 42px 0px 42px; padding-top: 2px;">
				' . (!empty($order->gift_message) ? '<div style="border: 1px dashed #999; padding: 5px; margin-top: 8px;"><b>' . $this->l('Message:') . '</b><br />' . nl2br2($order->gift_message) . '</div>' : '') : '<img src="../img/admin/disabled.gif" />') . '
			</div>
		</fieldset>';
        echo '</div>
		<div class="clear">&nbsp;</div>';
        /* Display adresses : delivery & invoice */
        echo '<div class="clear">&nbsp;</div>
		<div style="float: left">
			<fieldset style="width: 400px;">
				<legend><img src="../img/admin/delivery.gif" alt="' . $this->l('Shipping address') . '" />' . $this->l('Shipping address') . '</legend>
				<div style="float: right">
					<a href="?tab=AdminAddresses&id_address=' . $addressDelivery->id . '&addaddress&realedit=1&id_order=' . $order->id . ($addressDelivery->id == $addressInvoice->id ? '&address_type=1' : '') . '&token=' . Tools::getAdminToken('AdminAddresses' . (int) Tab::getIdFromClassName('AdminAddresses') . (int) $cookie->id_employee) . '&back=' . urlencode($_SERVER['REQUEST_URI']) . '"><img src="../img/admin/edit.gif" /></a>
					<a href="http://maps.google.com/maps?f=q&hl=' . $currentLanguage->iso_code . '&geocode=&q=' . $addressDelivery->address1 . ' ' . $addressDelivery->postcode . ' ' . $addressDelivery->city . ($addressDelivery->id_state ? ' ' . $deliveryState->name : '') . '" target="_blank"><img src="../img/admin/google.gif" alt="" class="middle" /></a>
				</div>
				' . $this->displayAddressDetail($addressDelivery) . (!empty($addressDelivery->other) ? '<hr />' . $addressDelivery->other . '<br />' : '') . '</fieldset>
		</div>
		<div style="float: left; margin-left: 40px">
			<fieldset style="width: 400px;">
				<legend><img src="../img/admin/invoice.gif" alt="' . $this->l('Invoice address') . '" />' . $this->l('Invoice address') . '</legend>
				<div style="float: right"><a href="?tab=AdminAddresses&id_address=' . $addressInvoice->id . '&addaddress&realedit=1&id_order=' . $order->id . ($addressDelivery->id == $addressInvoice->id ? '&address_type=2' : '') . '&back=' . urlencode($_SERVER['REQUEST_URI']) . '&token=' . Tools::getAdminToken('AdminAddresses' . (int) Tab::getIdFromClassName('AdminAddresses') . (int) $cookie->id_employee) . '"><img src="../img/admin/edit.gif" /></a></div>
				' . $this->displayAddressDetail($addressInvoice) . (!empty($addressInvoice->other) ? '<hr />' . $addressInvoice->other . '<br />' : '') . '</fieldset>
		</div>
		<div class="clear">&nbsp;</div>';
        // List of products
        echo '
		<a name="products"><br /></a>
		<form action="' . $currentIndex . '&submitCreditSlip&vieworder&token=' . $this->token . '" method="post" onsubmit="return orderDeleteProduct(\'' . $this->l('Cannot return this product') . '\', \'' . $this->l('Quantity to cancel is greater than quantity available') . '\');">
			<input type="hidden" name="id_order" value="' . $order->id . '" />
			<fieldset style="width: 868px; ">
				<legend><img src="../img/admin/cart.gif" alt="' . $this->l('Products') . '" />' . $this->l('Products') . '</legend>
				<div style="float:left;">
					<table style="width: 868px;" cellspacing="0" cellpadding="0" class="table" id="orderProducts">
						<tr>
							<th align="center" style="width: 60px">&nbsp;</th>
							<th>' . $this->l('Product') . '</th>
							<th style="width: 80px; text-align: center">' . $this->l('UP') . ' <sup>*</sup></th>
							<th style="width: 20px; text-align: center">' . $this->l('Qty') . '</th>
							' . ($order->hasBeenPaid() ? '<th style="width: 20px; text-align: center">' . $this->l('Refunded') . '</th>' : '') . '
							' . ($order->hasBeenDelivered() ? '<th style="width: 20px; text-align: center">' . $this->l('Returned') . '</th>' : '') . '
							<th style="width: 30px; text-align: center">' . $this->l('Stock') . '</th>
							<th style="width: 90px; text-align: center">' . $this->l('Total') . ' <sup>*</sup></th>
							<th colspan="2" style="width: 120px;"><img src="../img/admin/delete.gif" alt="' . $this->l('Products') . '" /> ' . ($order->hasBeenDelivered() ? $this->l('Return') : ($order->hasBeenPaid() ? $this->l('Refund') : $this->l('Cancel'))) . '</th>';
        echo '
						</tr>';
        $tokenCatalog = Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee);
        foreach ($products as $k => $product) {
            if ($order->getTaxCalculationMethod() == PS_TAX_EXC) {
                $product_price = $product['product_price'] + $product['ecotax'];
            } else {
                $product_price = $product['product_price_wt'];
            }
            $image = array();
            if (isset($product['product_attribute_id']) and (int) $product['product_attribute_id']) {
                $image = Db::getInstance()->getRow('
								SELECT id_image
								FROM ' . _DB_PREFIX_ . 'product_attribute_image
								WHERE id_product_attribute = ' . (int) $product['product_attribute_id']);
            }
            if (!isset($image['id_image']) or !$image['id_image']) {
                $image = Db::getInstance()->getRow('
								SELECT id_image
								FROM ' . _DB_PREFIX_ . 'image
								WHERE id_product = ' . (int) $product['product_id'] . ' AND cover = 1');
            }
            $stock = Db::getInstance()->getRow('
							SELECT ' . ($product['product_attribute_id'] ? 'pa' : 'p') . '.quantity
							FROM ' . _DB_PREFIX_ . 'product p
							' . ($product['product_attribute_id'] ? 'LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON p.id_product = pa.id_product' : '') . '
							WHERE p.id_product = ' . (int) $product['product_id'] . '
							' . ($product['product_attribute_id'] ? 'AND pa.id_product_attribute = ' . (int) $product['product_attribute_id'] : ''));
            if (isset($image['id_image'])) {
                $target = _PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg';
                if (file_exists($target)) {
                    $products[$k]['image_size'] = getimagesize($target);
                }
            }
            // Customization display
            $this->displayCustomizedDatas($customizedDatas, $product, $currency, $image, $tokenCatalog, $k);
            // Normal display
            if ($product['product_quantity'] > $product['customizationQuantityTotal']) {
                $quantity = $product['product_quantity'] - $product['customizationQuantityTotal'];
                $imageObj = new Image($image['id_image']);
                echo '
								<tr' . ((isset($image['id_image']) and isset($products[$k]['image_size'])) ? ' height="' . ($products[$k]['image_size'][1] + 7) . '"' : '') . '>
									<td align="center">' . (isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_ . 'p/' . $imageObj->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg', 45, 'jpg') : '--') . '</td>
									<td><a href="index.php?tab=AdminCatalog&id_product=' . $product['product_id'] . '&updateproduct&token=' . $tokenCatalog . '">
										<span class="productName">' . $product['product_name'] . '</span><br />
										' . ($product['product_reference'] ? $this->l('Ref:') . ' ' . $product['product_reference'] . '<br />' : '') . ($product['product_supplier_reference'] ? $this->l('Ref Supplier:') . ' ' . $product['product_supplier_reference'] : '') . '</a></td>
									<td align="center">' . Tools::displayPrice($product_price, $currency, false) . '</td>
									<td align="center" class="productQuantity" ' . ($quantity > 1 ? 'style="font-weight:700;font-size:1.1em;color:red"' : '') . '>' . (int) $quantity . '</td>
									' . ($order->hasBeenPaid() ? '<td align="center" class="productQuantity">' . (int) $product['product_quantity_refunded'] . '</td>' : '') . '
									' . ($order->hasBeenDelivered() ? '<td align="center" class="productQuantity">' . (int) $product['product_quantity_return'] . '</td>' : '') . '
									<td align="center" class="productQuantity">' . (int) $stock['quantity'] . '</td>
									<td align="center">' . Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int) $product['product_quantity'] - $product['customizationQuantityTotal']), $currency, false) . '</td>
									<td align="center" class="cancelCheck">
										<input type="hidden" name="totalQtyReturn" id="totalQtyReturn" value="' . (int) $product['product_quantity_return'] . '" />
										<input type="hidden" name="totalQty" id="totalQty" value="' . (int) $product['product_quantity'] . '" />
										<input type="hidden" name="productName" id="productName" value="' . $product['product_name'] . '" />';
                if ((!$order->hasBeenDelivered() or Configuration::get('PS_ORDER_RETURN')) and (int) $product['product_quantity_return'] < (int) $product['product_quantity']) {
                    echo '
										<input type="checkbox" name="id_order_detail[' . $k . ']" id="id_order_detail[' . $k . ']" value="' . $product['id_order_detail'] . '" onchange="setCancelQuantity(this, ' . (int) $product['id_order_detail'] . ', ' . (int) ($product['product_quantity_in_stock'] - $product['customizationQuantityTotal'] - $product['product_quantity_reinjected']) . ')" ' . ((int) ($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int) $product['product_quantity'] ? 'disabled="disabled" ' : '') . '/>';
                } else {
                    echo '--';
                }
                echo '
									</td>
									<td class="cancelQuantity">';
                if ((int) ($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int) $product['product_quantity']) {
                    echo '<input type="hidden" name="cancelQuantity[' . $k . ']" value="0" />';
                } elseif (!$order->hasBeenDelivered() or Configuration::get('PS_ORDER_RETURN')) {
                    echo '
										<input type="text" id="cancelQuantity_' . (int) $product['id_order_detail'] . '" name="cancelQuantity[' . $k . ']" size="2" onclick="selectCheckbox(this);" value="" /> ';
                }
                echo $this->getCancelledProductNumber($order, $product) . '
									</td>
								</tr>';
            }
        }
        echo '
					</table>
					<div style="float:left; width:280px; margin-top:15px;"><sup>*</sup> ' . $this->l('According to the group of this customer, prices are printed:') . ' ' . ($order->getTaxCalculationMethod() == PS_TAX_EXC ? $this->l('tax excluded.') : $this->l('tax included.')) . (!Configuration::get('PS_ORDER_RETURN') ? '<br /><br />' . $this->l('Merchandise returns are disabled') : '') . '</div>';
        if (sizeof($discounts)) {
            echo '
					<div style="float:right; width:280px; margin-top:15px;">
					<table cellspacing="0" cellpadding="0" class="table" style="width:100%;">
						<tr>
							<th><img src="../img/admin/coupon.gif" alt="' . $this->l('Discounts') . '" />' . $this->l('Discount name') . '</th>
							<th align="center" style="width: 100px">' . $this->l('Value') . '</th>
						</tr>';
            foreach ($discounts as $discount) {
                echo '
						<tr>
							<td>' . $discount['name'] . '</td>
							<td align="center">' . ($discount['value'] != 0.0 ? '- ' : '') . Tools::displayPrice($discount['value'], $currency, false) . '</td>
						</tr>';
            }
            echo '
					</table></div>';
        }
        echo '
				</div>';
        // Cancel product
        echo '
				<div style="clear:both; height:15px;">&nbsp;</div>
				<div style="float: right; width: 160px;">';
        if ($order->hasBeenDelivered() and Configuration::get('PS_ORDER_RETURN')) {
            echo '
					<input type="checkbox" id="reinjectQuantities" name="reinjectQuantities" class="button" />&nbsp;<label for="reinjectQuantities" style="float:none; font-weight:normal;">' . $this->l('Re-stock products') . '</label><br />';
        }
        if (!$order->hasBeenDelivered() and $order->hasBeenPaid() or $order->hasBeenDelivered() and Configuration::get('PS_ORDER_RETURN')) {
            echo '
					<input type="checkbox" id="generateCreditSlip" name="generateCreditSlip" class="button" onclick="toogleShippingCost(this)" />&nbsp;<label for="generateCreditSlip" style="float:none; font-weight:normal;">' . $this->l('Generate a credit slip') . '</label><br />
					<input type="checkbox" id="generateDiscount" name="generateDiscount" class="button" onclick="toogleShippingCost(this)" />&nbsp;<label for="generateDiscount" style="float:none; font-weight:normal;">' . $this->l('Generate a voucher') . '</label><br />
					<span id="spanShippingBack" style="display:none;"><input type="checkbox" id="shippingBack" name="shippingBack" class="button" />&nbsp;<label for="shippingBack" style="float:none; font-weight:normal;">' . $this->l('Repay shipping costs') . '</label><br /></span>';
        }
        if (!$order->hasBeenDelivered() or $order->hasBeenDelivered() and Configuration::get('PS_ORDER_RETURN')) {
            echo '
					<div style="text-align:center; margin-top:5px;"><input type="submit" name="cancelProduct" value="' . ($order->hasBeenDelivered() ? $this->l('Return products') : ($order->hasBeenPaid() ? $this->l('Refund products') : $this->l('Cancel products'))) . '" class="button" style="margin-top:8px;" /></div>';
        }
        echo '
				</div>';
        echo '
			</fieldset>
		</form>
		<div class="clear" style="height:20px;">&nbsp;</div>';
        /* Display send a message to customer & returns/credit slip*/
        $returns = OrderReturn::getOrdersReturn($order->id_customer, $order->id);
        $slips = OrderSlip::getOrdersSlip($order->id_customer, $order->id);
        echo '
		<div style="float: left">
			<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&token=' . $this->token . '" method="post" onsubmit="if (getE(\'visibility\').checked == true) return confirm(\'' . $this->l('Do you want to send this message to the customer?', __CLASS__, true, false) . '\');">
			<fieldset style="width: 400px;">
				<legend style="cursor: pointer;" onclick="$(\'#message\').slideToggle();$(\'#message_m\').slideToggle();return false"><img src="../img/admin/email_edit.gif" /> ' . $this->l('New message') . '</legend>
				<div id="message_m" style="display: ' . (Tools::getValue('message') ? 'none' : 'block') . '; overflow: auto; width: 400px;">
					<a href="#" onclick="$(\'#message\').slideToggle();$(\'#message_m\').slideToggle();return false"><b>' . $this->l('Click here') . '</b> ' . $this->l('to add a comment or send a message to the customer') . '</a>
				</div>
				<div id="message" style="display: ' . (Tools::getValue('message') ? 'block' : 'none') . '">
					<select name="order_message" id="order_message" onchange="orderOverwriteMessage(this, \'' . $this->l('Do you want to overwrite your existing message?') . '\')">
						<option value="0" selected="selected">-- ' . $this->l('Choose a standard message') . ' --</option>';
        $orderMessages = OrderMessage::getOrderMessages((int) $order->id_lang);
        foreach ($orderMessages as $orderMessage) {
            echo '		<option value="' . htmlentities($orderMessage['message'], ENT_COMPAT, 'UTF-8') . '">' . $orderMessage['name'] . '</option>';
        }
        echo '		</select><br /><br />
					<b>' . $this->l('Display to consumer?') . '</b>
					<input type="radio" name="visibility" id="visibility" value="0" /> ' . $this->l('Yes') . '
					<input type="radio" name="visibility" value="1" checked="checked" /> ' . $this->l('No') . '
					<p id="nbchars" style="display:inline;font-size:10px;color:#666;"></p><br /><br />
					<textarea id="txt_msg" name="message" cols="50" rows="8" onKeyUp="var length = document.getElementById(\'txt_msg\').value.length; if (length > 600) length = \'600+\'; document.getElementById(\'nbchars\').innerHTML = \'' . $this->l('600 chars max') . ' (\' + length + \')\';">' . htmlentities(Tools::getValue('message'), ENT_COMPAT, 'UTF-8') . '</textarea><br /><br />
					<input type="hidden" name="id_order" value="' . (int) $order->id . '" />
					<input type="hidden" name="id_customer" value="' . (int) $order->id_customer . '" />
					<input type="submit" class="button" name="submitMessage" value="' . $this->l('Send') . '" />
				</div>
			</fieldset>
			</form>';
        /* Display list of messages */
        if (sizeof($messages)) {
            echo '
			<br />
			<fieldset style="width: 400px;">
			<legend><img src="../img/admin/email.gif" /> ' . $this->l('Messages') . '</legend>';
            foreach ($messages as $message) {
                echo '<div style="overflow:auto; width:400px;" ' . ($message['is_new_for_me'] ? 'class="new_message"' : '') . '>';
                if ($message['is_new_for_me']) {
                    echo '<a class="new_message" title="' . $this->l('Mark this message as \'viewed\'') . '" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&token=' . $this->token . '&messageReaded=' . (int) $message['id_message'] . '"><img src="../img/admin/enabled.gif" alt="" /></a>';
                }
                echo $this->l('At') . ' <i>' . Tools::displayDate($message['date_add'], (int) $cookie->id_lang, true);
                echo '</i> ' . $this->l('from') . ' <b>' . ($message['elastname'] ? $message['efirstname'] . ' ' . $message['elastname'] : $message['cfirstname'] . ' ' . $message['clastname']) . '</b>';
                echo (int) $message['private'] == 1 ? '<span style="color:red; font-weight:bold;">' . $this->l('Private:') . '</span>' : '';
                echo '<p>' . nl2br2($message['message']) . '</p>';
                echo '</div>';
                echo '<br />';
            }
            echo '<p class="info">' . $this->l('When you read a message, please click on the green check.') . '</p>';
            echo '</fieldset>';
        }
        echo '</div>';
        /* Display return product */
        echo '<div style="float: left; margin-left: 40px">
			<fieldset style="width: 400px;">
				<legend><img src="../img/admin/return.gif" alt="' . $this->l('Merchandise returns') . '" />' . $this->l('Merchandise returns') . '</legend>';
        if (!sizeof($returns)) {
            echo $this->l('No merchandise return for this order.');
        } else {
            foreach ($returns as $return) {
                $state = new OrderReturnState($return['state']);
                echo '(' . Tools::displayDate($return['date_upd'], $cookie->id_lang) . ') :
				<b><a href="index.php?tab=AdminReturn&id_order_return=' . $return['id_order_return'] . '&updateorder_return&token=' . Tools::getAdminToken('AdminReturn' . (int) Tab::getIdFromClassName('AdminReturn') . (int) $cookie->id_employee) . '">' . $this->l('#') . sprintf('%06d', $return['id_order_return']) . '</a></b> -
				' . $state->name[$cookie->id_lang] . '<br />';
            }
        }
        echo '</fieldset>';
        /* Display credit slip */
        echo '
				<br />
				<fieldset style="width: 400px;">
					<legend><img src="../img/admin/slip.gif" alt="' . $this->l('Credit slip') . '" />' . $this->l('Credit slip') . '</legend>';
        if (!sizeof($slips)) {
            echo $this->l('No slip for this order.');
        } else {
            foreach ($slips as $slip) {
                echo '(' . Tools::displayDate($slip['date_upd'], $cookie->id_lang) . ') : <b><a href="pdf.php?id_order_slip=' . $slip['id_order_slip'] . '">' . $this->l('#') . sprintf('%06d', $slip['id_order_slip']) . '</a></b><br />';
            }
        }
        echo '</fieldset>
		</div>';
        echo '<div class="clear">&nbsp;</div>';
        echo '<br /><br /><a href="' . $currentIndex . '&token=' . $this->token . '"><img src="../img/admin/arrow2.gif" /> ' . $this->l('Back to list') . '</a><br />';
    }
Ejemplo n.º 18
0
<?php

$useSSL = true;
include dirname(__FILE__) . '/config/config.inc.php';
include dirname(__FILE__) . '/header.php';
$errors = array();
$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));
if (Tools::isSubmit('submitMessage')) {
    $message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
    if (!($from = Tools::getValue('from')) or !Validate::isEmail($from)) {
        $errors[] = Tools::displayError('invalid e-mail address');
    } elseif (!($message = nl2br2($message))) {
        $errors[] = Tools::displayError('message cannot be blank');
    } elseif (!Validate::isMessage($message)) {
        $errors[] = Tools::displayError('invalid message');
    } elseif (!($id_contact = intval(Tools::getValue('id_contact'))) or !Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))) {
        $errors[] = Tools::displayError('please select a contact in the list');
    } else {
        if (intval($cookie->id_customer)) {
            $customer = new Customer(intval($cookie->id_customer));
        }
        if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, intval($cookie->id_customer) ? $customer->firstname . ' ' . $customer->lastname : $from)) {
            $smarty->assign('confirmation', 1);
        } else {
            $errors[] = Tools::displayError('an error occurred while sending message');
        }
    }
}
$email = Tools::safeOutput(Tools::getValue('from', (isset($cookie) and isset($cookie->email) and Validate::isEmail($cookie->email)) ? $cookie->email : ''));
$smarty->assign(array('errors' => $errors, 'email' => $email));
$smarty->display(_PS_THEME_DIR_ . 'contact-form.tpl');
    public function preProcess()
    {
        parent::preProcess();
        if (self::$cookie->isLogged()) {
            self::$smarty->assign('isLogged', 1);
            $customer = new Customer((int) self::$cookie->id_customer);
            if (!Validate::isLoadedObject($customer)) {
                die(Tools::displayError('Customer not found'));
            }
            $products = array();
            $orders = array();
            $getOrders = Db::getInstance()->ExecuteS('
				SELECT id_order
				FROM ' . _DB_PREFIX_ . 'orders
				WHERE id_customer = ' . (int) $customer->id . ' ORDER BY date_add');
            foreach ($getOrders as $row) {
                $order = new Order($row['id_order']);
                $date = explode(' ', $order->date_add);
                $orders[$row['id_order']] = Tools::displayDate($date[0], self::$cookie->id_lang);
                $tmp = $order->getProducts();
                foreach ($tmp as $key => $val) {
                    $products[$val['product_id']] = $val['product_name'];
                }
            }
            $orderList = '';
            foreach ($orders as $key => $val) {
                $orderList .= '<option value="' . $key . '" ' . ((int) Tools::getValue('id_order') == $key ? 'selected' : '') . ' >' . $key . ' -- ' . $val . '</option>';
            }
            $orderedProductList = '';
            foreach ($products as $key => $val) {
                $orderedProductList .= '<option value="' . $key . '" ' . ((int) Tools::getValue('id_product') == $key ? 'selected' : '') . ' >' . $val . '</option>';
            }
            self::$smarty->assign('orderList', $orderList);
            self::$smarty->assign('orderedProductList', $orderedProductList);
        }
        if (Tools::isSubmit('submitMessage')) {
            $fileAttachment = NULL;
            if (isset($_FILES['fileUpload']['name']) and !empty($_FILES['fileUpload']['name']) and !empty($_FILES['fileUpload']['tmp_name'])) {
                $extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
                $filename = uniqid() . substr($_FILES['fileUpload']['name'], -5);
                $fileAttachment['content'] = file_get_contents($_FILES['fileUpload']['tmp_name']);
                $fileAttachment['name'] = $_FILES['fileUpload']['name'];
                $fileAttachment['mime'] = $_FILES['fileUpload']['type'];
            }
            $message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
            if (!($from = trim(Tools::getValue('from'))) or !Validate::isEmail($from)) {
                $this->errors[] = Tools::displayError('Invalid e-mail address');
            } elseif (!($message = nl2br2($message))) {
                $this->errors[] = Tools::displayError('Message cannot be blank');
            } elseif (!Validate::isCleanHtml($message)) {
                $this->errors[] = Tools::displayError('Invalid message');
            } elseif (!($id_contact = (int) Tools::getValue('id_contact')) or !Validate::isLoadedObject($contact = new Contact((int) $id_contact, (int) self::$cookie->id_lang))) {
                $this->errors[] = Tools::displayError('Please select a subject on the list.');
            } elseif (!empty($_FILES['fileUpload']['name']) and $_FILES['fileUpload']['error'] != 0) {
                $this->errors[] = Tools::displayError('An error occurred during the file upload');
            } elseif (!empty($_FILES['fileUpload']['name']) and !in_array(substr($_FILES['fileUpload']['name'], -4), $extension) and !in_array(substr($_FILES['fileUpload']['name'], -5), $extension)) {
                $this->errors[] = Tools::displayError('Bad file extension');
            } else {
                if ((int) self::$cookie->id_customer) {
                    $customer = new Customer((int) self::$cookie->id_customer);
                } else {
                    $customer = new Customer();
                    $customer->getByEmail($from);
                }
                $contact = new Contact($id_contact, self::$cookie->id_lang);
                if (!($id_customer_thread = (int) Tools::getValue('id_customer_thread') and (int) Db::getInstance()->getValue('
						SELECT cm.id_customer_thread FROM ' . _DB_PREFIX_ . 'customer_thread cm
						WHERE cm.id_customer_thread = ' . (int) $id_customer_thread . ' AND token = \'' . pSQL(Tools::getValue('token')) . '\'') or $id_customer_thread = (int) Db::getInstance()->getValue('
						SELECT cm.id_customer_thread FROM ' . _DB_PREFIX_ . 'customer_thread cm
						WHERE cm.email = \'' . pSQL($from) . '\' AND cm.id_order = ' . (int) Tools::getValue('id_order') . ''))) {
                    $fields = Db::getInstance()->ExecuteS('
					SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
					FROM ' . _DB_PREFIX_ . 'customer_thread cm
					WHERE email = \'' . pSQL($from) . '\' AND (' . ($customer->id ? 'id_customer = ' . (int) $customer->id . ' OR ' : '') . '
						id_order = ' . (int) Tools::getValue('id_order') . ')');
                    $score = 0;
                    foreach ($fields as $key => $row) {
                        $tmp = 0;
                        if ((int) $row['id_customer'] and $row['id_customer'] != $customer->id and $row['email'] != $from) {
                            continue;
                        }
                        if ($row['id_order'] != 0 and Tools::getValue('id_order') != $row['id_order']) {
                            continue;
                        }
                        if ($row['email'] == $from) {
                            $tmp += 4;
                        }
                        if ($row['id_contact'] == $id_contact) {
                            $tmp++;
                        }
                        if (Tools::getValue('id_product') != 0 and $row['id_product'] == Tools::getValue('id_product')) {
                            $tmp += 2;
                        }
                        if ($tmp >= 5 and $tmp >= $score) {
                            $score = $tmp;
                            $id_customer_thread = $row['id_customer_thread'];
                        }
                    }
                }
                $old_message = Db::getInstance()->getValue('
					SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
					WHERE cm.id_customer_thread = ' . (int) $id_customer_thread . '
					ORDER BY date_add DESC');
                if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8')) {
                    self::$smarty->assign('alreadySent', 1);
                    $contact->email = '';
                    $contact->customer_service = 0;
                }
                if (!empty($contact->email)) {
                    if (Mail::Send((int) self::$cookie->id_lang, 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (int) self::$cookie->id_customer ? $customer->firstname . ' ' . $customer->lastname : '', $fileAttachment) and Mail::Send((int) self::$cookie->id_lang, 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from)) {
                        self::$smarty->assign('confirmation', 1);
                    } else {
                        $this->errors[] = Tools::displayError('An error occurred while sending message.');
                    }
                }
                if ($contact->customer_service) {
                    if ((int) $id_customer_thread) {
                        $ct = new CustomerThread($id_customer_thread);
                        $ct->status = 'open';
                        $ct->id_lang = (int) self::$cookie->id_lang;
                        $ct->id_contact = (int) $id_contact;
                        if ($id_order = (int) Tools::getValue('id_order')) {
                            $ct->id_order = $id_order;
                        }
                        if ($id_product = (int) Tools::getValue('id_product')) {
                            $ct->id_product = $id_product;
                        }
                        $ct->update();
                    } else {
                        $ct = new CustomerThread();
                        if (isset($customer->id)) {
                            $ct->id_customer = (int) $customer->id;
                        }
                        if ($id_order = (int) Tools::getValue('id_order')) {
                            $ct->id_order = $id_order;
                        }
                        if ($id_product = (int) Tools::getValue('id_product')) {
                            $ct->id_product = $id_product;
                        }
                        $ct->id_contact = (int) $id_contact;
                        $ct->id_lang = (int) self::$cookie->id_lang;
                        $ct->email = $from;
                        $ct->status = 'open';
                        $ct->token = Tools::passwdGen(12);
                        $ct->add();
                    }
                    if ($ct->id) {
                        $cm = new CustomerMessage();
                        $cm->id_customer_thread = $ct->id;
                        $cm->message = htmlentities($message, ENT_COMPAT, 'UTF-8');
                        if (isset($filename) and rename($_FILES['fileUpload']['tmp_name'], _PS_MODULE_DIR_ . '../upload/' . $filename)) {
                            $cm->file_name = $filename;
                        }
                        $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
                        $cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
                        if ($cm->add()) {
                            if (empty($contact->email)) {
                                Mail::Send((int) self::$cookie->id_lang, 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);
                            }
                            self::$smarty->assign('confirmation', 1);
                        } else {
                            $this->errors[] = Tools::displayError('An error occurred while sending message.');
                        }
                    } else {
                        $this->errors[] = Tools::displayError('An error occurred while sending message.');
                    }
                }
                if (count($this->errors) > 1) {
                    array_unique($this->errors);
                }
            }
        }
    }
Ejemplo n.º 20
0
function clean_utf8($str)
{
    return nl2br2(trim(utf8_encode(htmlentities(smartQuotesUE($str)))));
}
Ejemplo n.º 21
0
 public function processData()
 {
     if (Module::isInstalled('agilemultipleshop') && Shop::$id_shop_owner > 0) {
         if (!Validate::isLoadedObject($this->seller)) {
             $this->errors[] = Tools::displayError('Seller does not exist');
         } elseif (!$this->seller->active) {
             self::$smarty->assign('seller', $this->seller);
         } else {
             $rewrited_url = self::$link->getAgileSellerLink((int) $this->seller->id, $this->getSellerLinkRwrite());
             $this->seller_info->description = _PS_VERSION_ > '1.5' ? Tools::nl2br($this->seller_info->description) : nl2br2($this->seller_info->description);
             // Setting language and language level
             $language_level = explode(',', $this->seller_info->language_level);
             $language = explode(',', $this->seller_info->language);
             $language_array = array();
             for ($x = 0; $x < count($language); $x++) {
                 $language_array[] = $language[$x] . ' - ' . $language_level[$x];
             }
             $this->seller_info->language = $language_array;
             self::$smarty->assign('seller', $this->seller);
             self::$smarty->assign('seller_info', $this->seller_info);
             $imgPath = _PS_ROOT_DIR_ . DS . 'img' . DS . 'as' . DS . $this->seller_info->id_sellerinfo;
             $licenseImg = _PS_ROOT_DIR_ . DS . 'img' . DS . 'as' . DS . $this->seller_info->id_sellerinfo . '_license';
             $images = scandir($imgPath);
             unset($images[0]);
             unset($images[1]);
             $images = array_values($images);
             @($licenseDir = scandir($licenseImg));
             $licenseExist = count($licenseDir) > 2 ? 1 : 0;
             $this->seller_info->seller_images = $images;
             $sellermodule = new AgileMultipleSeller();
             $conf = Configuration::getMultiple($sellermodule->getCustomFields());
             $custom_labels = $sellermodule->getCustomLabels();
             self::$smarty->assign('conf', $conf);
             self::$smarty->assign('custom_labels', $custom_labels);
             $nbProducts = $this->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
             $this->pagination((int) $nbProducts);
             self::$smarty->assign('nb_products', (int) $nbProducts);
             $seller_products = $this->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay);
             AgileHelper::AssignProductImgs($seller_products);
             $si_1531_later = version_compare(_PS_VERSION_, '1.5.3.1', ">=");
             $HOOK_SELLER_RATINGS = '';
             if (Module::isInstalled('agilesellerratings')) {
                 require_once _PS_ROOT_DIR_ . "/modules/agilesellerratings/agilesellerratings.php";
                 $rmodule = new AgileSellerRatings();
                 $HOOK_SELLER_RATINGS = $rmodule->getAverageRating($this->id_seller, AgileSellerRatings::RATING_TYPE_SELLER);
             }
             /*foreach($seller_products as $k => $v) {
             			$country = $v['country'];
             			$flagId = Country::getIdByName(1, $country);
             			$seller_products[$k]['img_exist']	= file_exists(_PS_ROOT_DIR_ . DS . 'flag' . DS . 'mini'. DS . $flagId . '.jpg')? 1 : 0;
             			$seller_products[$k]['img_name']	= $flagId . '.jpg';
             		}*/
             foreach ($seller_products as $key => $value) {
                 $seller_id = $value['id_seller'];
                 $flagIds = self::getFlagsId($seller_id);
                 foreach ($flagIds as $k => $flgId) {
                     $seller_products[$key]['img_exist'][$k] = file_exists(_PS_ROOT_DIR_ . DS . 'flag' . DS . 'mini' . DS . $flgId . '.jpg') ? 1 : 0;
                     $seller_products[$key]['img_name'][$k] = $flgId . '.jpg';
                 }
             }
             // die('<pre>' . print_r($seller_products, true));
             self::$smarty->assign(array('products' => (isset($seller_products) and $seller_products) ? $seller_products : NULL, 'license_exist' => $licenseExist, 'id_seller' => (int) $this->seller->id, 'path' => $this->seller_info->company, 'agilesellerproducts_tpl' => _PS_ROOT_DIR_ . "/modules/agilesellerproducts/", 'agilemultipleshop_tpl' => _PS_ROOT_DIR_ . "/modules/agilemultipleshop/", 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('category') : 'category'), 'mediumSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('medium') : 'medium'), 'thumbSceneSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('thumb_scene') : 'thumb_scene'), 'homeSize' => Image::getSize($si_1531_later ? ImageType::getFormatedName('home') : 'home'), 'HOOK_SELLER_RATINGS' => $HOOK_SELLER_RATINGS, 'page_name' => 'agileseller'));
             $ver = (int) str_replace(".", "", _PS_VERSION_);
             if ($ver <= 1430) {
             } else {
                 if ($ver <= 1451) {
                     if (isset(self::$cookie->id_customer)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer));
                     } elseif (isset(self::$cookie->id_guest)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest));
                     }
                 } else {
                     if (isset(self::$cookie->id_compare)) {
                         self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int) self::$cookie->id_compare));
                     }
                 }
             }
         }
         self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
     }
 }
Ejemplo n.º 22
0
include '../includes/form_validation_includes.php';
?>
	<style type="text/css">
	@import url("/css/main-css.css")
        </style>
<?php 
include_once '../mysql/hidden_files/database.php';
include_once '../classes/class.goals.crud.php';
if (isset($_POST['btn-save'])) {
    $week_code = htmlspecialchars($_POST['week_code']);
    $title = htmlspecialchars($_POST['title']);
    $message = nl2br2($_POST['message']);
    $link_label = htmlspecialchars($_POST['link_label']);
    $link = htmlspecialchars($_POST['link']);
    $img_link = htmlspecialchars($_POST['img_link']);
    $notes = nl2br2($_POST['notes']);
    $query = "INSERT INTO xff_wk_messages (\n                    week_code,\n                    title,\n                    message,\n                    link_label,\n                    link,\n                    img_link,\n                    notes) VALUES (\n                    :week_code,\n                    :title,\n                    :message,\n                    :link_label,\n                    :link,\n                    :img_link,\n                    :notes)";
    $stmt = $conn->prepare($query);
    $stmt->bindParam(':week_code', $week_code, PDO::PARAM_STR);
    $stmt->bindParam(':title', $title, PDO::PARAM_STR);
    $stmt->bindParam(':message', $message, PDO::PARAM_STR);
    $stmt->bindParam(':link_label', $link_label, PDO::PARAM_STR);
    $stmt->bindParam(':link', $link, PDO::PARAM_STR);
    $stmt->bindParam(':img_link', $img_link, PDO::PARAM_STR);
    $stmt->bindParam(':notes', $notes, PDO::PARAM_STR);
    if ($stmt->execute()) {
        //header("Location: ../mysql/add_goals.php?inserted");
        ?>
       <script> location.replace("../mysql/add_messages.php?inserted"); </script>?<?php 
    } else {
        ?>
Ejemplo n.º 23
0
<?php 
include '../includes/form_validation_includes.php';
?>
	<style type="text/css">
	@import url("/css/main-css.css")
        </style>
<?php 
include_once '../mysql/hidden_files/database.php';
include_once '../classes/class.goals.crud.php';
$crud = new crud($conn);
if (isset($_POST['btn-save'])) {
    $user_id = $_POST["uid"];
    $username = $_POST['username'];
    $timeframe = $_POST['timeframe'];
    $goal = nl2br2($_POST['goal']);
    $actions = nl2br2($_POST['actions']);
    if ($crud->create($user_id, $username, $timeframe, $goal, $actions)) {
        //header("Location: ../mysql/add_goals.php?inserted");
        ?>
       <script> location.replace("../mysql/add_goals.php?inserted"); </script>?<?php 
    } else {
        ?>
       <script> location.replace("../mysql/add_goals.php?failure"); </script>?<?php 
    }
}
?>
  
 </head>
  
  <body >
    
Ejemplo n.º 24
0
<?php

$useSSL = true;
include dirname(__FILE__) . '/config/config.inc.php';
include dirname(__FILE__) . '/header.php';
$errors = array();
$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));
if (Tools::isSubmit('submitMessage')) {
    if (!($from = Tools::getValue('from')) or !Validate::isEmail($from)) {
        $errors[] = Tools::displayError('invalid e-mail address');
    } elseif (!($message = nl2br2(Tools::getValue('message')))) {
        $errors[] = Tools::displayError('message cannot be blank');
    } elseif (!Validate::isMessage($message)) {
        $errors[] = Tools::displayError('invalid message');
    } elseif (!($id_contact = intval(Tools::getValue('id_contact'))) or !Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))) {
        $errors[] = Tools::displayError('please select a contact in the list');
    } else {
        if (intval($cookie->id_customer)) {
            $customer = new Customer(intval($cookie->id_customer));
        }
        if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, intval($cookie->id_customer) ? $customer->firstname . ' ' . $customer->lastname : $from)) {
            $smarty->assign('confirmation', 1);
        } else {
            $errors[] = Tools::displayError('an error occurred while sending message');
        }
    }
}
$email = Tools::getValue('from', (isset($cookie) and isset($cookie->email) and Validate::isEmail($cookie->email)) ? $cookie->email : '');
$smarty->assign(array('errors' => $errors, 'email' => $email));
$smarty->display(_PS_THEME_DIR_ . 'contact-form.tpl');
include dirname(__FILE__) . '/footer.php';
Ejemplo n.º 25
0
// Loop through array items, and create JS calls to populate form
reset($inputArray);
if (sizeOf($inputArray) > 1) {
    $numCols = sizeOf($inputArray[2]);
    $numRows = sizeOf($inputArray);
    // Make calls to addColHead for each item in row 1
    echo 'function setup2() {';
    for ($header = 0; $header < $numCols; $header++) {
        echo 'addColumn("' . $inputArray[2][$header][0] . '","' . $inputArray[2][$header][1] . '") ;' . "\n";
    }
    for ($line = 3; $line < $numRows; $line++) {
        // Add a row
        echo "var newRow = addRow(false);\n";
        for ($col = 0; $col < $numCols; $col++) {
            // Add td
            echo 'addDataCell(newRow, "' . $inputArray[2][$col][1] . '","' . nl2br2(stripSlashes($inputArray[$line][$col])) . '") ;' . "\n";
        }
    }
    echo 'setRowButtons() ;';
    echo '}';
}
if ($_SESSION['loginStatus'] > 1) {
    echo 'var adminStatus = true ;';
} else {
    echo 'var adminStatus = false ;';
}
?>
	// -->
	</script>
	<style type="text/css">
		body {
 public function process()
 {
     parent::process();
     if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) {
         $this->errors[] = Tools::displayError('Missing category ID');
     } else {
         if (!Validate::isLoadedObject($this->category)) {
             $this->errors[] = Tools::displayError('Category does not exist');
         } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) {
             $this->errors[] = Tools::displayError('You do not have access to this category.');
         } elseif (!$this->category->active) {
             self::$smarty->assign('category', $this->category);
         } else {
             $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite);
             /* Scenes  (could be externalised to another controler if you need them */
             self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false));
             /* Scenes images formats */
             if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) {
                 foreach ($sceneImageTypes as $sceneImageType) {
                     if ($sceneImageType['name'] == 'thumb_scene') {
                         $thumbSceneImageType = $sceneImageType;
                     } elseif ($sceneImageType['name'] == 'large_scene') {
                         $largeSceneImageType = $sceneImageType;
                     }
                 }
                 self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
                 self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
             }
             $this->category->description = nl2br2($this->category->description);
             $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang);
             self::$smarty->assign('category', $this->category);
             if (Db::getInstance()->numRows()) {
                 self::$smarty->assign('subcategories', $subCategories);
                 self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
             }
             if ($this->category->id != 1) {
                 $nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
                 $this->pagination((int) $nbProducts);
                 self::$smarty->assign('nb_products', (int) $nbProducts);
                 $cat_products = $this->category->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay);
                 if ($cat_products) {
                     foreach ($cat_products as $cat_product) {
                         $prod_features[$cat_product["id_product"]] = Product::getFrontFeaturesStatic(self::$cookie->id_lang, $cat_product['id_product']);
                         $aux_product = new Product($cat_product["id_product"], true, self::$cookie->id_lang);
                         $aux_attributesGroups = $aux_product->getAttributesGroups((int) self::$cookie->id_lang);
                         foreach ($aux_attributesGroups as $k => $row) {
                             $aux_combinations[$row['attribute_name']]['price'] = (double) $row['price'];
                         }
                         $prod_combinations[$cat_product["id_product"]] = $aux_combinations;
                         unset($aux_combinations);
                     }
                 }
             }
             if (isset($prod_features)) {
                 self::$smarty->assign('prod_features', $prod_features);
             }
             if (isset($prod_combinations)) {
                 self::$smarty->assign('prod_combinations', $prod_combinations);
             }
             self::$smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home')));
             foreach ($subCategories as $subCat) {
                 $secondLevelCats[$subCat["id_category"]] = $this->getSubCats($subCat["id_category"]);
             }
             if (isset($secondLevelCats)) {
                 self::$smarty->assign('secondLevelCats', $secondLevelCats);
             }
         }
     }
     self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
 }
Ejemplo n.º 27
0
function print_reports($week, $user, $team)
{
    sql_con();
    echo '<table border=1><th>Sr.No.</th><th>Team</th><th>Project</th><th width=400>Task</th><th>Percent</th><th>Week</th>';
    /* All Weeks */
    if ($week == 1) {
        if ($user == 'All') {
            $user_select_query = "select user as User from team where level <\n\t\t\t\t\t      (select level from team where user = '******'Name'] . "'\n\t\t\t\t\t      and team_name = '" . $team . "') and team_name = '" . $team . "'";
            $query = "select * from week_report where user in (" . $user_select_query . ") and\n\t\t\t\t  team = '" . $team . "' order by week_report.user";
        } else {
            $query = "SELECT * FROM week_report where User='******' and team='{$team}'";
        }
    } else {
        $monday = get_monday(get_week($week));
        if ($user == 'All') {
            $user_select_query = "select user as User from team where level <\n\t\t\t\t\t      (select level from team where user = '******'Name'] . "'\n\t\t\t\t\t      and team_name = '" . $team . "') and team_name = '" . $team . "'";
            $query = "select * from week_report where Week = '{$monday}' and user in\n\t\t\t\t  (" . $user_select_query . ") and team = '" . $team . "' order by week_report.user";
        } else {
            $query = "SELECT * FROM week_report where Week = '{$monday}' and User='******' and team='{$team}'";
        }
    }
    $result = mysql_query($query) or die(mysql_error());
    $no_of_rows = mysql_num_rows($result);
    $tmp_user = "";
    $i = 1;
    while ($row = mysql_fetch_array($result, MYSQL_BOTH) and $i <= $no_of_rows) {
        if ($tmp_user != $row["User"] && $user == 'All') {
            $tmp_user = $row["User"];
            printf('<tr><td colspan="3">' . $tmp_user . '</td>');
        }
        $str = $row["Task"];
        print '<tr><td>' . $i . '</td><td>' . $team . '</td><td>' . $row["Project"] . '</td><td>' . nl2br1(nl2br2($str)) . '</td><td>' . $row["Percent"] . '</td><td>' . $row["Week"] . '</tr>';
        $i++;
    }
    echo '</table>';
    mysql_close(con);
}
Ejemplo n.º 28
0
/**
 * Sanitize data which will be injected into SQL query
 *
 * @param string $string SQL data which will be injected into SQL query
 * @param boolean $htmlOK Does data contain HTML code ? (optional)
 * @return string Sanitized data
 */
function pSQL($string, $htmlOK = false)
{
    if (_TAS_MAGIC_QUOTES_GPC_) {
        $string = stripslashes($string);
    }
    if (!is_numeric($string)) {
        $link = Db::getInstance()->getRessource();
        $string = _TAS_MYSQL_REAL_ESCAPE_STRING_ ? mysql_real_escape_string($string, $link) : addslashes($string);
        if (!$htmlOK) {
            $string = strip_tags(nl2br2($string));
        }
    }
    return $string;
}
Ejemplo n.º 29
0
/**
 * Sanitize data which will be injected into SQL query
 *
 * @param string $string SQL data which will be injected into SQL query
 * @param boolean $htmlOK Does data contain HTML code ? (optional)
 * @return string Sanitized data
 */
function pSQL($string, $htmlOK = false)
{
    if (_PS_MAGIC_QUOTES_GPC_) {
        $string = stripslashes($string);
    }
    if (!is_numeric($string)) {
        $string = _PS_MYSQL_REAL_ESCAPE_STRING_ ? mysql_real_escape_string($string) : addslashes($string);
        if (!$htmlOK) {
            $string = strip_tags(nl2br2($string));
        }
    }
    return $string;
}
Ejemplo n.º 30
0
    $str = trim($str);
    $f_str = preg_replace("/\\([A-Da-d]\\)/", "", substr($str, 0, 3)) . substr($str, 3);
    return html_entity_decode(trim($f_str));
}
function process_answer_option($str)
{
    $ansArray = array("1" => "A", "2" => "B", "3" => "C", "4" => "D");
    $str = trim($str);
    if (preg_match("/\\((.*)\\)/", $str, $matches) == 1) {
        return array_search(trim($matches[1]), $ansArray);
    }
    return "";
}
// Retrieve the DOM from a given URL
//$html = file_get_html('file:///var/www/html/quizmaster/upload/uk.html');
$html = nl2br2(file_get_contents('/var/www/html/quizmaster/upload/tobeuploaded/UPHJS Pre 2014 | Uttar Pradesh Higher Judicial Service (Preliminary) Examination- 2014 text.html'));
//echo $html;
$htmlArray = explode("<br />", $html);
$out = fopen('/var/www/html/quizmaster/upload/new.csv', 'w');
fputcsv($out, array('question', 'option_1', 'option_2', 'option_3', 'option_4', 'correct_answer', 'category', 'explanation', 'multi_answer'));
// Find all "span" tags and print their HREFs
$cnt = count($htmlArray);
$i = 0;
while ($i < $cnt) {
    $i++;
    $data = array();
    $data['question'] = process_question($htmlArray[$i++]);
    $data['option_1'] = process_answer($htmlArray[$i++]);
    $data['option_2'] = process_answer($htmlArray[$i++]);
    $data['option_3'] = process_answer($htmlArray[$i++]);
    $data['option_4'] = process_answer($htmlArray[$i++]);