public function indexAction() { $this->view->headTitle('Accueil'); $sell = new Application_Model_Sell(); $product = $sell->getNewsArticles(10); $product = $sell->convertImageSousRubrique($product); $this->view->product = $product; $general = new Application_Model_General(); $data_webite = $general->getGeneral(); $data = $data_webite[0]; $this->view->catchphrase = $data['catchphrase']; $general = new Application_Model_General(); $slider = $general->getSlider(); $this->view->slider = $slider; }
public function modifyAction() { $ns = new Zend_Session_Namespace('user'); if (empty($ns->data)) { $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'error', 'type' => 'page'), null, true)); } $fiche = $this->_getParam('fiche'); $article = new Application_Model_Sell(); $ns = new Zend_Session_Namespace('user'); $sell = new Application_Model_Sell(); $images = new Application_Model_Image(); $categorys = new Application_Model_Category(); $this->view->souscategory = $categorys->getSousRubrique(); $this->view->category = $categorys->getRubrique(); $sousRubriqueChoisi = $categorys->getSousRubrique(); $produit = $article->getArticle($fiche); foreach ($sousRubriqueChoisi as $s) { if ($produit[0]['id_category'] == $s['id_category']) { $sr = $s['label_category']; } } $this->view->sr = $sr; if ($this->_request->isPost()) { $title = $_POST['title']; if ($title == "") { $title = $produit[0]['title']; } // image data $image = @file_get_contents($_FILES['image']['tmp_name']); $nameImage = $_FILES['image']['name']; // sell data $quantity = $_POST['quantity']; $category = $_POST['category']; $price = $_POST['price']; $descritptionCourt = $_POST['description_courte']; $description = $_POST['description']; $idUser = $ns->data['id_user']; $sousrubrique = $_POST['sous-rubrique-hidden']; if ($sousrubrique == "") { $sousrubrique = $produit[0]['id_category']; } // recuperation de idSell après modification $sell->updateSell($title, $image, $quantity, $price, $descritptionCourt, $description, $fiche, $sousrubrique); // insertion de l'image grace a l'idSell $produit = $article->getArticle($fiche); if ($nameImage != '') { $ResultImage = $images->updateImage($produit[0]['id_image'], $image, $nameImage); } if ($ResultImage == true) { $this->_redirect($this->view->url(array('controller' => 'article', 'action' => 'modify', 'fiche' => $fiche, 'message' => 'done'), null, true)); } } $this->view->produit = $produit; foreach ($this->view->produit as &$p) { $p['img64'] = base64_encode($p['image']); $p['type'] = pathinfo($p['name_image'], PATHINFO_EXTENSION); } }
public function addcommandLine($idCommand, $panier) { $flag = true; $article = new Application_Model_Sell(); foreach ($panier as $idProduct => $qte) { $price = $article->getArticle($idProduct, array()); try { $data = array('id_command' => $idCommand, 'id_sell' => $idProduct, 'quantity' => $qte, 'price' => $price[0]['price']); $this->insert($data); $QtTotal = $article->getArticle($idProduct, array()); $val = $QtTotal[0]['quantity'] - $qte; $article->updateQuantitySell($val, $idProduct); } catch (Exception $ex) { echo 'ERROR_INSERT_ADDCOMMANDLINE : ' . $ex->getMessage(); return false; } } return $flag; }
public function articleAction() { $ns = new Zend_Session_Namespace('user'); $sell = new Application_Model_Sell(); $images = new Application_Model_Image(); if (empty($ns->data)) { $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'error', 'type' => 'page'), null, true)); } if ($this->_request->isPost()) { if ($this->_getParam('type') == 'ajout') { $title = $_POST['productTitle']; // image data $image = @file_get_contents($_FILES['image']['tmp_name']); $nameImage = $_FILES['image']['name']; // sell data $quantity = $_POST['productQuantite']; $category = $_POST['sous-rubrique-hidden']; $price = $_POST['productPrix']; $descritptionCourt = $_POST['productDescritptionCourte']; $descritption = $_POST['descritption']; $idUser = $ns->data['id_user']; // recuperation de idSell après insertion $idSell = $sell->addSell($title, $quantity, $category, $price, $descritptionCourt, $descritption, $idUser); // insertion de l'image grace a l'idSell $ResultImage = $images->addImage($idSell, $image, $nameImage); if ($ResultImage == true) { $this->_redirect($this->view->url(array('controller' => 'user', 'action' => 'article', 'message' => 'done'), null, true)); } } if ($this->_getParam('type') == 'update') { $idSell = $_POST['idSell']; $quantity = $_POST['quantity']; $price = $_POST['price']; $sell->updatePriceQuantity($quantity, $price, $idSell); $this->view->message = "Modification(s) sauvegard�(s)"; } } $commande = new Application_Model_Command(); $commandeline = new Application_Model_Commandline(); //Les produits de l'utilisateur achetés par d'autre clients. //$this->view->commande = $commande->getIdCommand($ns->data['id_user']); // Achat du client $tabCommand = $commande->getIdCommand($ns->data['id_user']); $this->view->command = $tabCommand; $this->view->commandeLine = $commandeline->getCommmandLine($tabCommand); //var_dump($this->view->commandeLine); die; $sell = new Application_Model_Sell(); $images = new Application_Model_Image(); $categorys = new Application_Model_Category(); $user = new Application_Model_User(); //Historique des vente effectué par un vendeur : Visualisation des commandes des clients $idProduct = $sell->getIdProductBySeller($ns->data['id_user']); $Commande = $commandeline->getCommandLineByArrayIdProduct($idProduct, true); $detailCommand = $commandeline->getCommandLineByArrayIdProduct($idProduct); $this->view->commandVente = $Commande; $complementCommand = $commandeline->getCommandLineByArrayIdProduct($idProduct); $this->view->complementCommande = $complementCommand; $this->view->detailCommand = $detailCommand; $infoUser = $user->getUserByCommandLine($Commande); $this->view->infoBuyer = $infoUser; $this->view->category = $categorys->getRubrique(); $this->view->souscategory = $categorys->getSousRubrique(); $table = $sell->getUserSell($ns->data['id_user']); foreach ($table as &$value) { $value['image'] = base64_encode($value['image']); $value['name_image'] = pathinfo($table['name_image'], PATHINFO_EXTENSION); } $this->view->articles = $table; }