Current File : /home/k/a/r/karenpetzb/www/items/category/controllers.zip |
PK �0H[�\�ϻ% �% StatisticController.phpnu &1i� <?php
class Backoffice_StatisticController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Logs";
$this->isConnectedWithRole('isStats');
}
function indexAction()
{
$this->_forward('/');
}
function logdefaultcleanAction() {
$logDefault = new LogDefault();
$logDefault->delete("1=1");
$this->_forward('logdefault');
}
function logadmincleanAction() {
$logAdmin = new LogAdmin();
$logAdmin->delete("1=1");
$this->_forward('logadmin');
}
function statsAction() {
try {
$this->view->titlePage = "Logs des administrateurs";
$this->view->currentMenu = "Stats";
$command = new Command();
$this->view->statsBestSellYear = $command->statsBestSellForYear();
$this->view->statsBestSellMonth = $command->statsBestSellForMonth();
$this->view->statsNbProductYear = $command->statsNbProductYear();
$this->view->statsNbProductMonth = $command->statsNbProductMonth();
$this->view->statsCategoryCmdYear = $command->statsCategoryCmdYear();
$this->view->statsCategoryCmdMonth = $command->statsCategoryCmdMonth();
$statsSearch = new StatsSearch();
$this->view->statsKeyWordYear = $statsSearch->statsKeyWordYear();
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
function logadminAction() {
try {
$this->view->titlePage = "Logs des administrateurs";
$this->view->currentMenu = "Logs";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'DATE_LOG';
$tri = 'DESC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triAdminCol_logadmin = $this->_request->getParam('col');
($adminNamespace->triAdminSens_logadmin == 'ASC') ? $adminNamespace->triAdminSens_logadmin = 'DESC' : $adminNamespace->triAdminSens_logadmin = 'ASC';
}
if (isset($adminNamespace->triAdminCol_logadmin)) {
$table = $adminNamespace->triAdminCol_logadmin;
$tri = $adminNamespace->triAdminSens_logadmin;
}
if (!isset($adminNamespace->triAdminNumber_logadmin)) {
$adminNamespace->triAdminNumber_logadmin = 100;
}
if ($this->_request->getParam('nb')) {
$adminNamespace->triAdminNumber_logadmin = $this->_request->getParam('nb');
}
$paginationNumber = $adminNamespace->triAdminNumber_logadmin;
$logAdmin = new LogAdmin();
$listlogs = $logAdmin->select()->order($table.' '.$tri);
$this->setPaginator($listlogs, $this->_getParam('page',1), $paginationNumber);
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
function logdefaultAction() {
try {
$this->view->titlePage = "Logs des utilisateurs";
$this->view->currentMenu = "Logs";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'DATE_LOG';
$tri = 'DESC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triAdminCol_logdefault = $this->_request->getParam('col');
($adminNamespace->triAdminSens_logdefault == 'ASC') ? $adminNamespace->triAdminSens_logdefault = 'DESC' : $adminNamespace->triAdminSens_logdefault = 'ASC';
}
if (isset($adminNamespace->triAdminCol_logdefault)) {
$table = $adminNamespace->triAdminCol_logdefault;
$tri = $adminNamespace->triAdminSens_logdefault;
}
if (!isset($adminNamespace->triAdminNumber_logdefault)) {
$adminNamespace->triAdminNumber_logdefault = 100;
}
if ($this->_request->getParam('nb')) {
$adminNamespace->triAdminNumber_logdefault = $this->_request->getParam('nb');
}
$paginationNumber = $adminNamespace->triAdminNumber_logdefault;
$logDefault = new LogDefault();
$listlogs = $logDefault->select()->order($table.' '.$tri);
$this->setPaginator($listlogs, $this->_getParam('page',1), $paginationNumber);
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
function searchkeyAction() {
try {
$this->view->titlePage = "Liste des recherches";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'DATESTART';
$tri = 'DESC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triAdminCol_logsearch = $this->_request->getParam('col');
($adminNamespace->triAdminSens_logsearch == 'ASC') ? $adminNamespace->triAdminSens_logsearch = 'DESC' : $adminNamespace->triAdminSens_logsearch = 'ASC';
}
if (isset($adminNamespace->triAdminCol_logsearch)) {
$table = $adminNamespace->triAdminCol_logsearch;
$tri = $adminNamespace->triAdminSens_logsearch;
}
if (!isset($adminNamespace->triAdminNumber_logsearch)) {
$adminNamespace->triAdminNumber_logsearch = 100;
}
if ($this->_request->getParam('nb')) {
$adminNamespace->triAdminNumber_logsearch = $this->_request->getParam('nb');
}
$paginationNumber = $adminNamespace->triAdminNumber_logsearch;
$statsSearch = new StatsSearch();
$listlogs = $statsSearch->select()->order($table.' '.$tri);
$this->setPaginator($listlogs, $this->_getParam('page',1), $paginationNumber);
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
function keymapAction() {
try {
$this->view->titlePage = "Carte des mots cl�s";
$adminNamespace = $this->getSession();
$keymap = new KeyMap();
$this->view->listMapCat = $keymap->getAllByCAT();
$this->view->listMapBrend = $keymap->getAllByBREND();
$categorie = new Category();
$select = $categorie->select()->order('NOM ASC');
$this->view->listCat = $categorie->fetchAll($select);
$brend = new SupplierBrend();
$select = $brend->select()->order('BREND ASC');
$this->view->listBrend = $brend->fetchAll($select);
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
function keymapcateditAction() {
try {
if ($this->_request->isPost()) {
$params = $this->_request->getPost();
$catId = (int) $params['catId'];
$color = 'DEFAULT';
if (!empty($params['colorKey'])) {
$color = $params['colorKey'];
}
if ($catId > 0) {
$keymap = new KeyMap();
$key = $keymap->getKeyByCatID($catId);
if (isset($key) && $key != null && !empty($key['CAT_NOM'])) {
$data = array (
'SIZE' => $params['sizeKey'],
'POSITION' => $params['positionKey'],
'TYPE' => 'CAT',
'COLOR' => $color
);
$keymap->update($data, 'ID = '.$key['ID']);
} else {
$data = array (
'CATID' => $catId,
'SIZE' => $params['sizeKey'],
'POSITION' => $params['positionKey'],
'TYPE' => 'CAT',
'COLOR' => $color
);
$keymap->insert($data);
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
$this->_forward('/keymap');
}
function keymapbrendeditAction() {
try {
if ($this->_request->isPost()) {
$params = $this->_request->getPost();
$brendId = (int) $params['brendId'];
$color = 'DEFAULT';
if (!empty($params['colorKey'])) {
$color = $params['colorKey'];
}
if ($brendId > 0) {
$keymap = new KeyMap();
$key = $keymap->getKeyByBrendID($brendId);
if (isset($key) && $key != null && !empty($key['BREND_NOM'])) {
$data = array (
'SIZE' => $params['sizeKey'],
'POSITION' => $params['positionKey'],
'TYPE' => 'BREND',
'COLOR' => $color
);
$keymap->update($data, 'ID = '.$key['ID']);
} else {
$data = array (
'BRENDID' => $brendId,
'SIZE' => $params['sizeKey'],
'POSITION' => $params['positionKey'],
'TYPE' => 'BREND',
'COLOR' => $color
);
$keymap->insert($data);
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
$this->_forward('/keymap');
}
function keymapshowAction()
{
if ($this->_request->isPost()) {
$params = $this->_request->getPost();
if ($params['keyType'] == 'CAT') {
$id = $params['catIdShow'];
} else {
$id = $params['brendIdShow'];
}
$data = array('isSHOW' => $params['showvalue']);
try {
if ( $id > 0) {
$keymap = new KeyMap();
if ($params['keyType'] == 'CAT') {
$keymap->update($data, 'CATID = '.$id);
} else {
$keymap->update($data, 'BRENDID = '.$id);
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
$this->_forward('/keymap');
}
}
$this->_forward('/keymap');
}
function clickstatsipAction() {
try {
$this->view->titlePage = "Statistiques des clicks";
$clickStats = new ClickStats();
$this->view->listSource = $clickStats->getSourceStats();
$listIp = $clickStats->getIPStats();
$this->view->listIp = $listIp;
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
function clickstatsproductAction() {
try {
$this->view->titlePage = "Statistiques des clicks";
$clickStats = new ClickStats();
$this->view->listClick = $clickStats->getProductDetail();
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
?>PK �0H[`�;= ;= CommandController.phpnu &1i� <?php
class Backoffice_CommandController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Command";
$this->isConnectedWithRole('isCommand');
}
function indexAction()
{
$this->_forward('/listcommand');
}
function searchAction()
{
try {
$this->view->titlePage = "Rechercher une commande";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$startSearch = false;
$isCheckedValidating = false;
$searchValue = "";
if ($this->_request->isPost()) {
$post = $this->_request->getPost();
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
$searchValue = $filter->filter($post['searchValue']);
if (isset($post['searchType'])) {
$isCheckedValidating = true;
}
$startSearch = true;
}
//Gestion des tris
$titlePage = "";
$listcommand = array();
if ($startSearch) {
$adminNamespace = $this->getSession();
$adminNamespace->cmdSearchValue = $searchValue;
$adminNamespace->cmdSearchValidating = $isCheckedValidating;
//Appel model pour listing
$command = new Command();
$titlePage .= " : ".$searchValue;
$listcommand = $command->findCommandsByMultiSearch($isCheckedValidating, $searchValue);
}
$this->view->titlePage .= $titlePage;
$this->view->listcommand = $listcommand;
$this->view->searchType = $isCheckedValidating;
$this->view->searchValue = $searchValue;
} catch (Zend_Exception $e) { $this->errorHandler($e); $this->view->messageError = $e->getMessage(); }
}
function listAction()
{
$this->view->titlePage = "Gestion des commandes";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'STATUT';
$tri = 'ASC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triCmdCol = $this->_request->getParam('col');
($adminNamespace->triCmdSens == 'ASC') ? $adminNamespace->triCmdSens = 'DESC' : $adminNamespace->triCmdSens = 'ASC';
}
if (isset($adminNamespace->triCmdCol)) {
$table = $adminNamespace->triCmdCol;
$tri = $adminNamespace->triCmdSens;
}
//Appel model pour listing
$command = new Command();
$select = $command->select()->where('STATUT <> 0 AND isARCHIVE = 1')->order($table.' '.$tri);
$this->view->listcommand = $command->fetchAll($select);
}
function listcommandAction()
{
$this->view->titlePage = "Gestion des commandes";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'STATUT';
$tri = 'ASC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triCmdCol = $this->_request->getParam('col');
($adminNamespace->triCmdSens == 'ASC') ? $adminNamespace->triCmdSens = 'DESC' : $adminNamespace->triCmdSens = 'ASC';
}
if (isset($adminNamespace->triCmdCol)) {
$table = $adminNamespace->triCmdCol;
$tri = $adminNamespace->triCmdSens;
}
//Appel model pour listing
$command = new Command();
$select = $command->select()->where('isARCHIVE = 1 AND STATUT IN (1, 2, 3, 4)')->order($table.' '.$tri);
$this->view->listcommand = $command->fetchAll($select);
}
function listdevisAction()
{
$this->view->titlePage = "Gestion des devis";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'STATUT';
$tri = 'ASC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triCmdCol = $this->_request->getParam('col');
($adminNamespace->triCmdSens == 'ASC') ? $adminNamespace->triCmdSens = 'DESC' : $adminNamespace->triCmdSens = 'ASC';
}
if (isset($adminNamespace->triCmdCol)) {
$table = $adminNamespace->triCmdCol;
$tri = $adminNamespace->triCmdSens;
}
//Appel model pour listing
$command = new Command();
$select = $command->select()->where('isARCHIVE = 1 AND STATUT IN (10, 11)')->order($table.' '.$tri);
$this->view->listcommand = $command->fetchAll($select);
}
//Same as UserController, module default
private function computeFactureTVA($facture, $paysLivraison) {
$fact = new Facture();
$fact->computeFactureTVA($facture, $paysLivraison);
return $facture;
}
function editAction() {
try {
$this->view->messageSuccess = "";
$this->view->messageError = "";
$command = new Command();
if($this->getRequest()->isPost()) {
$id = (int)$this->_request->getPost('idcmd');
$statut = (int)$this->_request->getPost('statut');
$delivery_trackinglink = $this->_request->getPost('delivery_trackinglink');
$delivery_trackingnumber = $this->_request->getPost('delivery_trackingnumber');
if ($id > 0 && $statut>0) {
try {
if ($statut == 3 || $statut == 11) {
$date = new Zend_Date();
$data = array ( 'STATUT' => $statut, 'DATEEND' => $date->toString('YYYY-MM-dd HH:mm:ss') );
} else {
$data = array ( 'STATUT' => $statut, 'DATEEND' => '0000-00-00 00:00:00');
}
if (isset($delivery_trackinglink) && !empty($delivery_trackinglink) &&
isset($delivery_trackingnumber) && !empty($delivery_trackingnumber)) {
$data['DELIVERY_TRACKINGLINK'] = $delivery_trackinglink;
$data['DELIVERY_TRACKINGNUMBER'] = $delivery_trackingnumber;
}
$command->update($data, 'ID = '.$id);
$this->view->messageSuccess = "Le statut a �t� modifi�";
$this->log("Le statut a �t� modifi� : ".$id,'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
if ($this->getRequest()->getParam('id') && (int)$this->getRequest()->getParam('id')>0) {
$id = (int)$this->getRequest()->getParam('id');
}
$isExist = $command->fetchRow("ID = ".$id);
if ($isExist) {
$myCommand = $command->getCommandAsFacture($id);
$this->view->facture = $myCommand;
$titlePage = "Modifier une commande";
switch ($myCommand['STATUT']) {
case 10 :
$titlePage = "Modifier un devis";
break;
case 11 :
$titlePage = "Modifier un devis";
break;
}
$this->view->titlePage = $titlePage;
}
} catch (Zend_Exception $e) { $this->log($e->getMessage(), 'err'); }
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$command = new Command();
$commandProduct = new CommandProduct();
$commandProduct->delete('IDCOMMAND = '.$id);
$command->delete('ID = '.$id);
$this->view->messageSuccess = "La commande a �t� supprim�e ";
$this->log("La commande a �t� supprim�e",'info');
$adminNamespace = $this->getSession();
if (isset($adminNamespace->cmdSearchValue) && isset($adminNamespace->cmdSearchValidating)) {
$isCheckedValidating = $adminNamespace->cmdSearchValidating;
$searchValue = $adminNamespace->cmdSearchValue;
//Gestion des tris
$listcommand = array();
//Appel model pour listing
$titlePage = "Rechercher une commande : ".$searchValue;
$listcommand = $command->findCommandsByMultiSearch($isCheckedValidating, $searchValue);
$this->view->titlePage .= $titlePage;
$this->view->listcommand = $listcommand;
$this->view->searchType = $isCheckedValidating;
$this->view->searchValue = $searchValue;
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->render('search');
}
function ajaxdelcommandAction() {
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$command = new Command();
$commandProduct = new CommandProduct();
$commandProduct->delete('IDCOMMAND = '.$id);
$command->delete('ID = '.$id);
$this->view->messageSuccess = "SUCCESS";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "ERROR";
}
}
}
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxmessage');
}
function delcommandAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$command = new Command();
$commandProduct = new CommandProduct();
$commandProduct->delete('IDCOMMAND = '.$id);
$command->delete('ID = '.$id);
$this->view->messageSuccess = "La commande a �t� supprim�e ";
$this->log("La commande a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/listcommand');
}
function deldevisAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$command = new Command();
$commandProduct = new CommandProduct();
$commandProduct->delete('IDCOMMAND = '.$id);
$command->delete('ID = '.$id);
$this->view->messageSuccess = "Le devis a �t� supprim� ";
$this->log("Le devis a �t� supprim�",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/listdevis');
}
function archiveAction() {
if($this->getRequest()->isPost()) {
$checkBoxValues = $this->_request->getPost('checkBoxValues');
$checkBoxValues = substr($checkBoxValues, 0, -1);
try {
if (!empty($checkBoxValues)) {
$command = new Command();
$data = array ( 'isARCHIVE' => 0);
$command->update($data, 'ID in ('.$checkBoxValues.')');
$this->log("Les commandes ont �t� archiv�es "+$checkBoxValues,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
$this->_forward('/listcommand');
}
function archivecommandAction() {
if($this->getRequest()->isPost()) {
$checkBoxValues = $this->_request->getPost('checkBoxValues');
$checkBoxValues = substr($checkBoxValues, 0, -1);
try {
if (!empty($checkBoxValues)) {
$command = new Command();
$data = array ( 'isARCHIVE' => 0);
$command->update($data, 'ID in ('.$checkBoxValues.')');
$this->log("Les commandes ont �t� archiv�es "+$checkBoxValues,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
$this->_forward('/listcommand');
}
function archivedevisAction() {
if($this->getRequest()->isPost()) {
$checkBoxValues = $this->_request->getPost('checkBoxValues');
$checkBoxValues = substr($checkBoxValues, 0, -1);
try {
if (!empty($checkBoxValues)) {
$command = new Command();
$data = array ( 'isARCHIVE' => 0);
$command->update($data, 'ID in ('.$checkBoxValues.')');
$this->log("Les devis ont �t� archiv�es "+$checkBoxValues,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
$this->_forward('/listdevis');
}
function deliverymailAction() {
$id = 0;
if ($this->getRequest()->getParam('id') && (int)$this->getRequest()->getParam('id')>0) {
$id = (int)$this->getRequest()->getParam('id');
}
if ($id > 0) {
$command = new Command();
$isExist = $command->fetchRow("ID = ".$id);
if ($isExist) {
$facture = $command->getCommandAsFacture($id);
$this->view->facture =$facture;
if (isset($facture['DELIVERY_TRACKINGLINK']) && !empty($facture['DELIVERY_TRACKINGLINK']) &&
isset($facture['DELIVERY_TRACKINGNUMBER']) && !empty($facture['DELIVERY_TRACKINGNUMBER'])) {
try {
$view = new Zend_View();
$view->addScriptPath('../application/modules/backoffice/views/scripts/command/');
$view->assign("facture",$facture);
$body = $view->render("facture_deliverytrack.phtml");
$from = $this->serviceClient_Mail;
$objet = "Votre commande : ".$facture['REFERENCE'];
$to = $facture['USER_EMAIL'];
$mail = new Zend_Mail();
$mail->setBodyHtml($body);
$mail->setFrom($from, $this->siteName);
$mail->addTo($to);
$mail->setSubject($objet);
$mail->send();
$this->view->messageSuccess = "L'email de suivi de livraison a �t� envoy� a : ".$to;
$this->log("L'email de suivi de livraison a �t� envoy� a : ".$to,'info');
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
} else {
$this->view->messageError = "Vous devez valider l'ajout du lien de suivi de livraison";
}
}
}
$this->view->titlePage = "Modifier une commande";
$this->render("edit");
}
function traitementmailAction() {
$id = 0;
if ($this->getRequest()->getParam('id') && (int)$this->getRequest()->getParam('id')>0) {
$id = (int)$this->getRequest()->getParam('id');
}
if ($id > 0) {
$command = new Command();
$isExist = $command->fetchRow("ID = ".$id);
if ($isExist) {
$facture = $command->getCommandAsFacture($id);
$this->view->facture =$facture;
try {
$view = new Zend_View();
$view->addScriptPath('../application/modules/backoffice/views/scripts/command/');
$view->assign("facture",$facture);
$body = $view->render("facture_traitementinprogress.phtml");
$from = $this->serviceClient_Mail;
$objet = "Votre commande : ".$facture['REFERENCE'];
$to = $facture['USER_EMAIL'];
$mail = new Zend_Mail();
$mail->setBodyHtml($body);
$mail->setFrom($from, $this->siteName);
$mail->addTo($to);
$mail->setSubject($objet);
$mail->send();
$this->view->messageSuccess = "L'email de la commande en cours de traitement a �t� envoy� a : ".$to;
$this->log("L'email de la commande en cours de traitement a �t� envoy� a : ".$to,'info');
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
}
$this->view->titlePage = "Modifier une commande";
$this->render("edit");
}
}
?>PK �0H[(h h ProductController.phpnu &1i� <?php
class Backoffice_ProductController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Product";
$this->isConnectedWithRole('isProduct');
}
public function indexAction()
{
$this->_forward('/list');
}
private function indexproductById($id) {
try {
if ($id > 0) {
try
{
if (empty($this->FeatureElasticSearchWsdl) || empty($this->FeatureElasticSearchUsername) || empty($this->FeatureElasticSearchKey)) {
return ;
}
$soapClient = $this->getSoapClient($this->FeatureElasticSearchWsdl);
$request = $this->getSoapHeader($this->FeatureElasticSearchUsername, $this->FeatureElasticSearchKey);
$request->ProductId = $id;
$parameters = new stdClass();
$parameters->request = $request;
$soapClient->PushProduct($parameters);
$soapClient = null;
}
catch (SoapFault $fault)
{
$this->log('SOAP : indexproductById : '.$fault->faultcode.' '.$fault->faultstring,'err');
}
}
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
public function indexproductAction() {
try {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
$soapClient = $this->getSoapClient($this->FeatureElasticSearchWsdl);
$result = new stdClass();
try
{
$request = $this->getSoapHeader($this->FeatureElasticSearchUsername, $this->FeatureElasticSearchKey);
$request->ProductId = $id;
$parameters = new stdClass();
$parameters->request = $request;
$result = $soapClient->PushProduct($parameters);
}
catch (SoapFault $fault)
{
$this->log('SOAP : indexProductAction : '.$fault->faultcode.' '.$fault->faultstring,'err');
}
$soapClient = null;
}
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
$this->_forward('/edit');
}
public function uploadpicsAction() {
if(!empty($_FILES['file']) && !empty($_FILES['file']['name'])) {
$nomOrigine = $_FILES['file']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpeg", "jpg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
$repertoireDestination = 'items/product/'.$this->_request->getParam('idcat').'/';
$this->checkDirectoryExist($repertoireDestination);
/*$date = new Zend_Date();
$nomDestination = $date->toString('dd-MM-YYYY_HH-mm-ss').".".$extensionFichier;*/
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
$fileoriginal = $repertoireDestination.$nomDestination;
$adminNamespace = $this->getSession();
if (move_uploaded_file($_FILES["file"]["tmp_name"],$fileoriginal)) {
try {
$picture = new Picture();
$data = array (
'URL' => $fileoriginal,
'IDPRODUCT' => $this->_request->getParam('id'),
'POSITION' => $adminNamespace->imgPosDefault
);
$picture->insert($data);
$messageSuccess = "L'image a �t� ajout�e";
//Resize picture
$info = getimagesize($fileoriginal) ;
list($width_old, $height_old) = $info;
$maxwidth = $this->FeaturePictureResizeWidth;
$maxheight = $this->FeaturePictureResizeHeight;
if ($width_old > $maxwidth || $height_old > $maxheight) {
Utils_Tool::smart_resize_image($fileoriginal , null, $maxwidth , $maxheight , true , $fileoriginal , true , false ,50 );
$messageSuccess .= " et redimensionn�e.";
}
$this->view->messageSuccess = $messageSuccess;
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
}
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
}
$this->_forward('/edit');
}
public function editpictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$picture = new Picture();
for ($i=0; $i<$params['nbrImg']; $i++) {
$data = array (
'POSITION' => $params['position'.$i],
'STRING1' => $params['string1_'.$i],
'STRING2' => $params['string2_'.$i]
);
$picture->update($data,'ID = '.$params['id'.$i]);
}
$this->view->messageSuccess = "Les images ont �t� modifi�es";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
public function setpictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$picture = new Picture();
$adminNamespace = $this->getSession();
$data = array (
'URL' => $params['picture'],
'IDPRODUCT' => $this->_request->getParam('id'),
'POSITION' => $adminNamespace->imgPosDefault,
'STRING1' => '',
'STRING2' => ''
);
$picture->insert($data);
$this->view->messageSuccess = "Les images ont �t� modifi�es";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
public function delpictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('pic')) {
$id = (int)$this->_request->getParam('pic');
if ($id > 0) {
try {
$picture = new Picture();
$picture->delete('ID = '.$id);
$this->view->messageSuccess = "L'image a �t� supprim�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
public function erasepictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$product = new Product();
$sql = "
SELECT p.NOM NOM, p.ID ID
FROM product AS p
LEFT JOIN picture AS pic ON pic.IDPRODUCT = p.ID
WHERE pic.URL = '".$params['picture']."'
AND p.ID <> ".$params['id'];
$isExistProduct = $product->getAdapter()->fetchRow($sql);
$pic = new Picture();
if (!$isExistProduct) {
unlink($params['picture']);
$this->view->messageSuccess = "L'image a �t� supprim�e definitivement";
} else {
if ($isExistProduct['ID'] == $params['id']) {
unlink($params['picture']);
$pic->delete('URL LIKE ?',$params['picture']);
$this->view->messageSuccess = "L'image a �t� supprim�e definitivement";
} else {
$this->view->messageError = "L'image est utilis�e par : ".$isExistProduct['NOM'];
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
public function searchAction()
{
$this->view->titlePage = "Recherche avanc�e des produits";
$supplierBrend = new SupplierBrend();
$this->view->listbrend = $supplierBrend->fetchAll($supplierBrend->select()->order('BREND ASC'));
$adminNamespace = $this->getSession();
$option = new Option();
$this->view->listoption = $option->fetchAll();
$this->view->listSearch = array();
if ($this->_request->isPost() || isset($adminNamespace->searchCategory)) {
$params = $this->_request->getParams();
$filter = new Zend_Filter_StringTrim();
$nomtemp = $filter->filter($params['search']);
if (empty($nomtemp)) { $nomtemp = '%'; } else { $nomtemp = '%'.$nomtemp.'%'; }
if (!empty($params['prixMin']) && !empty($params['prixMax'])) { $params['prix'] = 'BETWEEN '.(float)$params['prixMin'].' AND '.(float)$params['prixMax'] ; }
$product = new Product();
$select = "
SELECT DISTINCT p.NOM NOM, p.DESCRIPTIONSHORT DESCRIPTIONSHORT, p.PRIX PRIX, p.ID ID, p.isACTIVE isACTIVE, p.isPROMO isPROMO
FROM product AS p
LEFT JOIN productchild AS pc ON pc.IDPRODUCT = p.ID
LEFT JOIN productchild_option AS pco ON pco.IDPRODUCTCHILD = pc.ID
LEFT JOIN product_option AS po ON po.IDPRODUCT = p.ID ";
if (!empty($params['image']) && $params['image']==0) { $select .= "LEFT JOIN picture AS pic ON pic.IDPRODUCT = p.ID "; }
$select .= "WHERE (p.NOM LIKE '".$nomtemp."' OR pc.REFERENCE LIKE '".$nomtemp."' OR pc.DESIGNATION LIKE '".$nomtemp."') ";
// Requete trop longue avec : OR p.DESCRIPTIONSHORT LIKE '".$nomtemp."' OR p.DESCRIPTIONTECH LIKE '".$nomtemp."' OR p.DESCRIPTIONLONG LIKE '".$nomtemp."' OR p.DESCRIPTIONNORME LIKE '".$nomtemp."'
if (!empty($params['prixMin']) && !empty($params['prixMax'])) { $select .= "AND (pc.PRIX >= ".$params['prixMin']." AND p.PRIX <= ".$params['prixMax'].") "; }
if (!empty($params['prixMin']) && empty($params['prixMax'])) { $select .= "AND pc.PRIX >= ".$params['prixMin']." "; }
if (empty($params['prixMin']) && !empty($params['prixMax'])) { $select .= "AND pc.PRIX <= ".$params['prixMax']." "; }
if (!empty($params['image']) && $params['image']==0) { $select .= "AND pic.POSITION = 1 "; }
if (!empty($params['image']) && $params['image']==1) { $select .= "AND NOT EXISTS ( SELECT * FROM picture pic WHERE pic.IDPRODUCT = p.ID AND pic.POSITION = 1) "; }
if (!empty($params['idcategorySearch']) && $params['idcategorySearch']!='All') { $select .= "AND p.IDCATEGORY = ".$params['idcategorySearch'].' '; }
if (!empty($params['active']) && $params['active']!=2) { $select .= "AND p.isACTIVE LIKE '".$params['active']."' "; }
if (!empty($params['activePromo']) && $params['activePromo']!=2) { $select .= "AND p.isPROMO LIKE '".$params['activePromo']."' "; }
if (!empty($params['idbrend']) && $params['idbrend']!='All') { $select .= "AND p.IDBREND = ".$params['idbrend']." "; }
if (!empty($params['etatstock']) && $params['etatstock']!=3) { $select .= "AND pc.ETATSTOCK LIKE '".$params['etatstock']."' "; }
if (!empty($params['optionId']) && $params['optionId']!='All') { $select .= "AND pco.IDOPTION LIKE '".$params['optionId']."' "; }
if (!empty($params['optionValue'])) { $select .= "AND pco.VALUE LIKE '".$params['optionValue']."' "; }
$select .= "ORDER BY NOM ASC";
try {
$picture = new Picture();
$sql = $picture->fetchAll('POSITION = 1');
$listpics = array();
foreach ($sql as $row) {
$listpics[$row['IDPRODUCT']] = $row['URL'];
}
$this->view->listproductpicture = $listpics;
$listTemp = $product->getAdapter()->fetchAll($select);
$this->view->listSearch = $listTemp;
if ($nomtemp == '%') {
$nomtemp = '';
}
$params['search'] = $filter->filter($params['search']);
if (!empty($params['search']) && empty($params['idcategorySearch'])) {
$params = array (
'search' => $params['search'],
'prixMin' => '',
'prixMax' => '',
'active' => '2',
'image' => '2',
'activePromo' => '2',
'idbrend' => 'All',
'etatstock' => '3',
'optionId' => 'All',
'optionValue' => '',
'idcategorySearch' => 'All'
);
}
$this->view->populateForm = $params;
$this->view->messageSuccess = count($listTemp).' Resultats';
$this->view->messageError = "";
} catch (Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageSuccess = "";
$this->view->messageError = $e->getMessage().' <br><br>'.$select;
}
} else {
$params = array (
'search' => '',
'prixMin' => '',
'prixMax' => '',
'active' => '2',
'image' => '2',
'activePromo' => '2',
'idbrend' => 'All',
'etatstock' => '3',
'optionId' => 'All',
'optionValue' => '',
'idcategorySearch' => 'All'
);
$this->view->populateForm = $params ;
}
}
public function listAction()
{
$this->view->titlePage = "Rechercher des produits";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'NOM';
$tri = 'ASC';
$this->view->searchCategory = 0;
$this->view->listproducts = array();
if ($this->_request->isPost() || isset($adminNamespace->searchCategory)) {
if ($this->_request->getParam('categorySearch') != null) {
$adminNamespace->searchCategory = $this->_request->getParam('categorySearch');
$adminNamespace->searchCategoryActive = "1";
if ($this->_request->getParam('isActive') != null) {
$adminNamespace->searchCategoryActive = "0";
}
}
$isActive = $adminNamespace->searchCategoryActive;
$id = $adminNamespace->searchCategory;
$this->view->searchCategory = $id;
$this->view->searchCategoryActive = $adminNamespace->searchCategoryActive;
//Appel model pour listing
$category = new Category();
$select = "
SELECT c0.ID ID0, c1.ID ID1, c2.ID ID2, c3.ID ID3, c4.ID ID4, c5.ID ID5,
c6.ID ID6, c7.ID ID7, c8.ID ID8, c9.ID ID9, c10.ID ID10
FROM category AS c0
LEFT JOIN category AS c1 ON c1.IDPARENT = c0.ID
LEFT JOIN category AS c2 ON c2.IDPARENT = c1.ID
LEFT JOIN category AS c3 ON c3.IDPARENT = c2.ID
LEFT JOIN category AS c4 ON c4.IDPARENT = c3.ID
LEFT JOIN category AS c5 ON c5.IDPARENT = c4.ID
LEFT JOIN category AS c6 ON c6.IDPARENT = c5.ID
LEFT JOIN category AS c7 ON c7.IDPARENT = c6.ID
LEFT JOIN category AS c8 ON c8.IDPARENT = c7.ID
LEFT JOIN category AS c9 ON c9.IDPARENT = c8.ID
LEFT JOIN category AS c10 ON c10.IDPARENT = c9.ID
WHERE c0.ID = ".$id;
$listTemp = $category->getAdapter()->fetchAll($select);
$listTemp2 = array();
$listCat = "";
foreach ($listTemp as $row) {
for ($level=0 ; $level<11; $level++) {
if ((!isset($listTemp2['ID'.$level]) || $listTemp2['ID'.$level] != $row['ID'.$level]) && $row['ID'.$level] != null) {
$listTemp2['ID'.$level] = $row['ID'.$level];
if ($listCat!="") {
$listCat .= ' ,'.$row['ID'.$level];
} else {
$listCat = $row['ID'.$level];
}
}
}
}
$select = "SELECT ID, NOM, DESCRIPTIONSHORT, PRIX, isACTIVE, isPROMO, IDCATEGORY
FROM product
WHERE IDCATEGORY IN (".$listCat.")
AND isACTIVE = ".$isActive."
ORDER BY NOM ASC";
$product = new Product();
$listprods = $product->getAdapter()->fetchAll($select);
$this->view->messageSuccess = sizeof($listprods)." resultats";
$picture = new Picture();
$sql = $picture->fetchAll('POSITION = 1');
$listpics = array();
foreach ($sql as $row) {
$listpics[$row['IDPRODUCT']] = $row['URL'];
}
$this->view->listproductpicture = $listpics;
$this->view->listproducts = $listprods;
}
}
public function editlistAction () {
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'NOM' => $filter->filter($params['nom']),
'DESCRIPTIONSHORT' => $filter->filter($params['descshort']),
'PRIX' => $filter->filter($params['prix'])
);
if ($validator->isValid($data['NOM']) &&
$validator->isValid($data['DESCRIPTIONSHORT']) &&
$validator->isValid($data['PRIX'])
) {
try {
$product = new Product();
$product->update($data, 'ID = '.$params['productid']);
$this->view->messageSuccess = "Le produit a �t� mis a jour";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
$this->_forward('/list');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/list');
}
public function addAction()
{
$this->view->titlePage = "Ajouter un produit";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$supplierBrend = new SupplierBrend();
$this->view->listbrend = $supplierBrend->fetchAll($supplierBrend->select()->order('BREND ASC'));
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$date = new Zend_Date();
$navtemp = $filter->filter($params['nom']);
$navnom = $this->generateNavigationString($navtemp);
$keywords = $this->generateKeyWords($navtemp);
$data = array (
'NOM' => $navtemp,
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'NAVTITRE' => $navtemp,
'NAVDESC' => $params['descshort'],
'DESCRIPTIONSHORT' => $params['descshort'],
'DESCRIPTIONLONG' => $params['desclong'],
'PRIX' => $filter->filter($params['prix']),
'isACTIVE' => $filter->filter($params['active']),
'DATEPROMO' => $date->toString('YYYY-MM-dd'),
'isPROMO' => '1',
'IDBREND' => $filter->filter($params['idbrend']),
'IDCATEGORY' => $filter->filter($params['idcategory'])
);
if ($validator->isValid($data['NOM']) &&
$validator->isValid($data['NAVNOM']) &&
$validator->isValid($data['DESCRIPTIONSHORT']) &&
$validator->isValid($data['DESCRIPTIONLONG']) &&
$validator->isValid($data['PRIX'])
) {
if ($data['IDBREND'] != 0) {
try {
$product = new Product();
$product->insert($data);
$this->view->messageSuccess = "Le produit a �t� ajout�";
$lastId = $product->getAdapter()->lastInsertId();
$this->_redirect('/backoffice/product/edit/showProduct/'.$lastId);
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
$this->view->populateForm = $data;
}
} else {
$this->view->messageError = "S�l�ctionner une marque";
$this->view->populateForm = $data;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateForm = $data;
}
} else {
$temp = array (
'NOM' => '',
'DESCRIPTIONSHORT' => '',
'DESCRIPTIONLONG' => '',
'PRIX' => '',
'IDBREND' => '',
'IDCATEGORY' => '',
'isACTIVE' => '1',
'isPROMO' => '1'
);
$this->view->populateForm = $temp;
}
}
private function computeUrlNavigationParent($row) {
return $row['NAVNOM_URLPARENTS']."/".$row['NAVNOM'];
}
public function editAction()
{
try {
$this->view->titlePage = "Modifier un Produit";
$isProcuctEnable = true;
$supplierBrend = new SupplierBrend();
$this->view->listbrend = $supplierBrend->fetchAll($supplierBrend->select()->order('BREND ASC'));
$option = new Option();
$this->view->listoption = $option->select()->order('NOM ASC')->query()->fetchAll();
$optionList = new OptionList();
$this->view->optionsbylist = $optionList->getAll();
$category2 = new Category2();
$this->view->listallcategories2 = $category2->getAllCategoriesByID(0);
$adminNamespace = $this->getSession();
$id = 0;
if ((int)$this->_request->getParam('showProduct') != null) {
$id = (int)$this->_request->getParam('showProduct');
} else if ((int)$this->_request->getParam('id') != null) {
$id = (int)$this->_request->getParam('id');
}
if ($id > 0) {
$picture = new Picture();
$listPicture = $picture->fetchAll('IDPRODUCT = '.$id);
$this->view->listPicture = $listPicture;
$productChildQte = new ProductChildQte();
$this->view->productChildQte = $productChildQte->getAllByProduct($id);
$product = new Product();
$row = $product->fetchRow('ID = '.$id);
if ($row) {
$currentProduct = $row->toArray();
$currentProduct['ONSELECT_OPTION'] = $optionList->getByIdProduct($id);
$currentProduct['PRIXLOWEST'] = $product->calculateLowestPrice($id);
$category = new Category();
$currentCategory = $category->fetchRow('ID = '.$currentProduct['IDCATEGORY']);
$currentProduct['NAVNOM_URLPARENTS'] = $this->computeUrlNavigationParent($currentCategory);
$this->view->populateForm = $currentProduct;
if ($currentProduct['isACTIVE'] == 1) {
$isProcuctEnable = false;
}
$isProductOutOfStock = false;
if ($currentProduct['STOCK'] == 4) {
$isProductOutOfStock = true;
}
$productCategory = new ProductCategory2();
$this->view->productCategories = $productCategory->getAllCategoriesByProductID($id);
if ($listPicture->count()<1) {
$this->view->messageError = "Aucune image n'est configur�e";
$adminNamespace->imgPosDefault = 1;
$isProcuctEnable = false;
} else {
$isOK = false;
foreach ($listPicture as $pic) {
if ($pic->POSITION == 1) {
$isOK = true;
break;
}
}
if (!$isOK) {
$this->view->messageError = "L'image principale n'est pas d�finie (1)";
$adminNamespace->imgPosDefault = 1;
//$isProcuctEnable = false;
} else {
$adminNamespace->imgPosDefault = $listPicture->count() + 1;
}
}
$this->view->isProcuctEnable = $isProcuctEnable;
$this->view->isProductOutOfStock = $isProductOutOfStock;
$productOption = new ProductOption();
$this->view->listproductoption = $productOption->getOptionsByIdProduct($id);
$productChild = new ProductChild();
$listProduct = $productChild->getChildsByIdProduct($id);
$listChild = array();
for ($i = 0; $i<sizeof($listProduct); $i++) {
$listChild[$listProduct[$i]['ID']]['ID'] = $listProduct[$i]['ID'];
$listChild[$listProduct[$i]['ID']]['REFERENCE'] = $listProduct[$i]['REFERENCE'];
$listChild[$listProduct[$i]['ID']]['POIDS'] = $listProduct[$i]['POIDS'];
$listChild[$listProduct[$i]['ID']]['DESIGNATION'] = $listProduct[$i]['DESIGNATION'];
$listChild[$listProduct[$i]['ID']]['PRIX'] = $listProduct[$i]['PRIX'];
$listChild[$listProduct[$i]['ID']]['ETATSTOCK'] = $listProduct[$i]['ETATSTOCK'];
$listChild[$listProduct[$i]['ID']]['isDEVIS'] = $listProduct[$i]['isDEVIS'];
$listChild[$listProduct[$i]['ID']]['isFRANCODENIED'] = $listProduct[$i]['isFRANCODENIED'];
$listChild[$listProduct[$i]['ID']]['QUANTITYMIN'] = $listProduct[$i]['QUANTITYMIN'];
$listChild[$listProduct[$i]['ID']]['isPROMO'] = $listProduct[$i]['isPROMO'];
$listChild[$listProduct[$i]['ID']]['POINTFIDELITE'] = $listProduct[$i]['POINTFIDELITE'];
$listChild[$listProduct[$i]['ID']]['IMAGEPROMO'] = $listProduct[$i]['IMAGEPROMO'];
$listChild[$listProduct[$i]['ID']]['OPTION_VALUE_'.$listProduct[$i]['IDOPTION']] = $listProduct[$i]['VALUE'];
$listChild[$listProduct[$i]['ID']]['OPTION_ID_'.$listProduct[$i]['IDOPTION']] = $listProduct[$i]['IDCHILD'];
}
$this->view->listChild = $listChild;
$childFTFDS = new ProductChildFTFDS();
$listFTFDS = $childFTFDS->getFTFDSByIdProduct($id);
$this->view->listFTFDS = $listFTFDS;
$productAccessoire = new ProductAccessoire();
$listAccessoires = $productAccessoire->getAccessoiresByProductID($id, 'pa.REFACCESSOIRE ASC');
$this->view->listAccessoires = $listAccessoires;
$productAnnexe = new ProductAnnexe();
$listAnnexes = $productAnnexe->getAnnexesByProductID($id, 'NOM ASC');;
$this->view->listAnnexes = $listAnnexes;
$this->view->currentProduct = $id;
$paramsXML = array(
'PRODUCT' => $currentProduct,
'PICS'=> $listPicture,
);
$this->view->siteMapShow = $this->generateSiteMapShow($paramsXML, $currentProduct['NAVNOM_URLPARENTS']);
} else {
$this->_forward('/list');
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
}
private function generateSiteMapShow($params, $navParentUrl) {
$navnoms = array();
$product = $params['PRODUCT'];
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
array_push($navnoms, str_replace("page/","",$filter->filter($product['NAVNOM'])));
array_push($navnoms, str_replace("page/","",$filter->filter($product['CUSTOM_NAVNOM1'])));
array_push($navnoms, str_replace("page/","",$filter->filter($product['CUSTOM_NAVNOM2'])));
array_push($navnoms, str_replace("page/","",$filter->filter($product['CUSTOM_NAVNOM3'])));
$br = "<br/>";
$tab = " ";
$tab2 = $tab.$tab.$tab;
$url = "";
foreach ($navnoms as $navnom) {
if (!empty($navnom)) {
$url .= $br.htmlentities("<url>");
$url .= $br.$tab;
$url .= htmlentities("<loc>".$this->baseUrl_SiteCommerceUrl."/".Utils_Tool::getFormattedUrlProduct($navParentUrl, $navnom, $product['ID'])."</loc>");
$url .= $br;
foreach($params['PICS'] as $row) {
$url .= $tab.htmlentities("<image:image>");
$url .= $br.$tab2;
$url .= htmlentities("<image:loc>".$this->baseUrl_SiteCommerceUrl."/".$row['URL']."</image:loc>");
if (!empty($row['STRING1'])) {
$url .= $br.$tab2;
$url .= htmlentities("<image:title>".$row['STRING1']."</image:title>");
}
if (!empty($row['STRING2'])) {
$url .= $br.$tab2;
$url .= htmlentities("<image:caption>".$row['STRING2']."</image:caption>");
}
$url .= $br.$tab;
$url .= htmlentities("</image:image>");
$url .= $br;
}
$url .= htmlentities("</url>");
}
}
return $url;
}
public function editproductAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//valideurs pour les chaines
$validator2 = new Zend_Validate();
$validator2 -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$isDevisProduct = 1;
if (isset($params['devisonproduct']) && $params['devisonproduct']) {
$isDevisProduct = 0;
}
$data = array (
'NOM' => $filter->filter($params['nom']),
'DESCRIPTIONSHORT' => $params['descshort'],
'DESCRIPTIONLONG' => $params['desclong'],
'DESCRIPTIONTECH' => $params['desctech'],
'DESCRIPTIONNORME' => $params['descnorme'],
'PRIX' => $filter->filter($params['prix']),
'isACTIVE' => $filter->filter($params['active']),
'IDCATEGORY' => (int)$filter->filter($params['idcategory']),
'DATEPROMO' => $params['sd'],
'ID' => $filter->filter($params['id']),
'IDBREND' => $filter->filter($params['idbrend']),
'isSHOWBREND' => $filter->filter($params['showbrend']),
'isDEVIS' => $isDevisProduct,
'STOCK' => (int)$params['stock'] ,
'BOOSTED_HOME' => (int)$params['boostedhome'],
'BOOSTED_BESTSELLER' => (int)$params['boostedbestseller']
);
if ($validator->isValid($data['NOM']) &&
$validator->isValid($data['DESCRIPTIONSHORT']) &&
$validator->isValid($data['DESCRIPTIONLONG']) &&
$validator2->isValid($data['PRIX'])
) {
try {
$product = new Product();
$product->update($data, 'ID = '.$data['ID']);
$this->view->messageSuccess = "Le produit a �t� modifi�";
$this->log("Le produit a �t� modifi� : ".$data['ID'],'info');
$this->indexproductById($data['ID']);
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "V�rifier les param�tres";
$this->view->populateForm = $data;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/edit');
}
public function editproductcategoriesAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//valideurs pour les chaines
$validator2 = new Zend_Validate();
$validator2 -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
try {
$id = (int) $params['id'];
$data = array (
'ID' => $id,
'IDCATEGORY_DUP1' => (int)$filter->filter($params['idcategory_duplicat1']),
'IDCATEGORY_DUP2' => (int)$filter->filter($params['idcategory_duplicat2']),
'IDCATEGORY_DUP3' => (int)$filter->filter($params['idcategory_duplicat3'])
);
$product = new Product();
$product->update($data, 'ID = '.$id);
if (!empty($params['idcategory_promosolde'])) {
$productCategory = new ProductCategory2();
$productCategory->delete('IDPRODUCT = '.$id);
foreach ($params['idcategory_promosolde'] as $row) {
if ((int)$row > 0) {
$dataTemp = array ('IDPRODUCT' => $id, 'IDCATEGORY' => (int)$row);
$productCategory->insert($dataTemp);
}
}
}
$this->view->messageSuccess = "Les cat�gories ont �t� modifi�es";
$this->log("Les cat�gories ont �t� modifi�es : ".$id,'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Les cat�gories n'ont pas �t� modifi�es";
$this->view->populateForm = $data;
}
}
$this->_forward('/edit');
}
public function editproductkeywordscleanAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
//get the form params
$id = (int)$this->_request->getParam('id');
$data = array ( 'KEYWORDS' => '' );
try {
if ($id > 0) {
$product = new Product();
$product->update($data, 'ID = '.$id);
$this->view->messageSuccess = "Les mots cl�s ont �t� modifi�s";
$this->log("Les mots cl�s ont �t� modifi�s : ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Les mots cl�s n'ont pas �t� modifi�s";
}
$this->_forward('/edit');
}
public function editproductkeywordsAction()
{
try {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$keywords = $this->generateKeyWords($params['nom']);
$data = array ( 'KEYWORDS' => $keywords );
if ($validator->isValid($data['KEYWORDS'])) {
$id = (int)$params['id'];
if ($id > 0) {
$product = new Product();
$product->update($data, 'ID = '.$id);
$this->view->messageSuccess = "Les mots cl�s ont �t� modifi�s";
$this->log("Les mots cl�s ont �t� modifi�s : ".$id,'info');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Les mots cl�s n'ont pas �t� modifi�s";
}
$this->_forward('/edit');
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$product = new Product();
$productOtion = new ProductOption();
$productChild = new ProductChild();
$productChildOption = new ProductChildOption();
$productAccessoire = new ProductAccessoire();
$picture = new Picture();
$childs = $productChild->fetchAll('IDPRODUCT = '.$id);
foreach ($childs as $row) {
$productChildOption->delete('IDPRODUCTCHILD = '.$row->ID);
$productAccessoire->delete('REFACCESSOIRE = "'.$row->REFERENCE.'"');
}
$productChild->delete('IDPRODUCT = '.$id);
$picture->delete('IDPRODUCT = '.$id);
$productOtion->delete('IDPRODUCT = '.$id);
$product->delete('ID = '.$id);
$this->view->messageSuccess = "Le produit a �t� supprim�";
$this->log("Le produit a �t� supprim�",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
public function editchildAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//valideurs pour les chaines
$validator2 = new Zend_Validate();
$validator2 -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$date = new Zend_Date();
$isDevisPrice = 1;
if (isset($params['devisprice']) && $params['devisprice']) {
$isDevisPrice = 0;
}
$quantiteMin = (int)$params['quantiteMin'];
if ($quantiteMin == 0) {
$quantiteMin = 1;
}
$dataChild = array (
'REFERENCE' => $filter->filter($params['reference']),
'DESIGNATION' => $filter->filter($params['designation']),
'PRIX' => $filter->filter($params['prixNormal']),
'ETATSTOCK' => $filter->filter($params['etatstock']),
'QUANTITYMIN' => $filter->filter($quantiteMin),
'isDEVIS' => $isDevisPrice,
'IMAGEPROMO' => $filter->filter($params['imagePromo']),
'DATEMODIF' => $date->toString('YYYY-MM-dd HH:mm:ss'),
'IDPRODUCT' => (int)$this->_request->getParam('id')
);
$listOption = unserialize($params['listOption']);
if ($validator->isValid($dataChild['REFERENCE']) &&
$validator2->isValid($dataChild['PRIX'])&&
$validator->isValid($dataChild['DESIGNATION'])
) {
try {
$productChild = new ProductChild();
$productChild->update($dataChild, 'ID = '.$params['idchild']);
$productChildOption = new ProductChildOption();
foreach ($listOption as $option) {
$dataOption = array (
'IDPRODUCTCHILD' => $params['idchild'],
'IDOPTION' => $option,
'VALUE' => $params['option'.$option]
);
$isOk = $productChildOption->update($dataOption,'IDPRODUCTCHILD = '.$params['idchild'].' AND IDOPTION = '.$option);
if (!$isOk) {
$productChildOption->delete('IDPRODUCTCHILD = '.$params['idchild'].' AND IDOPTION = '.$option);
$productChildOption->insert($dataOption);
}
}
$this->view->messageSuccess = "Le produit a ete modifie";
$this->log("Le produit child a ete modifie : ".$params['idchild'],'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La r�f�rence existe d�ja";
$this->view->populateChild = $dataChild;
$this->_forward('/edit');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateChild = $dataChild;
}
}
$this->_forward('/edit');
}
public function editchildsAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//get the form params
$params = $this->_request->getPost();
for ($index = 0; $index < $params['nbRows']; $index++) {
if (isset($params[$index."reference"]) && !empty($params[$index."reference"]) &&
isset($params[$index."designation"]) && !empty($params[$index."designation"])
) {
$optionsValues = array();
$listOption = unserialize($params['listOption']);
foreach ($listOption as $option) {
$optionsValues['option'.$option] = $params[$index."option".$option];
}
$isDevisPrice = 1;
if (isset($params[$index.'devisprice']) && $params[$index.'devisprice']) {
$isDevisPrice = 0;
}
$isFrancoDenied = 1;
if (isset($params[$index.'francodenied']) && $params[$index.'francodenied']) {
$isFrancoDenied = 0;
}
$this->editSingleChild($index,
$params,
$isDevisPrice,
$isFrancoDenied,
$listOption,
$optionsValues,
(int)$this->_request->getParam('id'));
}
}
}
$this->_forward('/edit');
}
private function editSingleChild($line, $paramsRequest, $isDevisPrice,$isFrancoDenied, $listOption, $optionsValues, $idProduct) {
$idChild = $paramsRequest[$line.'idchild'];
$quantity = $paramsRequest[$line.'quantiteMin'];
$reference = $paramsRequest[$line.'reference'];
$poids = $paramsRequest[$line.'poids'];
$designation = $paramsRequest[$line.'designation'];
$prixNormal =$paramsRequest[$line.'prixNormal'] ;
$etatstock = $paramsRequest[$line.'etatstock'];
$imagePromo = $paramsRequest[$line.'imagePromo'];
$pointFidelite = 0;
if (isset($paramsRequest[$line.'pointFidelite'])) {
$pointFidelite = (int)$paramsRequest[$line.'pointFidelite'];
}
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//valideurs pour les chaines
$validator2 = new Zend_Validate();
$validator2 -> addValidator(new Zend_Validate_NotEmpty());
$quantiteMin = (int)$quantity;
if ($quantiteMin == 0) {
$quantiteMin = 1;
}
$date = new Zend_Date();
$adminNamespace = $this->getSession();
$dataChildReturn = array (
$line.'REFERENCE' => $filter->filter($reference),
$line.'POIDS' => $filter->filter($poids),
$line.'DESIGNATION' => $designation,
$line.'PRIX' => $filter->filter($prixNormal),
$line.'ETATSTOCK' => $filter->filter($etatstock),
$line.'QUANTITYMIN' => $filter->filter($quantiteMin),
$line.'isDEVIS' => $isDevisPrice,
$line.'isFRANCODENIED' => $isFrancoDenied,
$line.'IMAGEPROMO' => $filter->filter($imagePromo),
$line.'DATEMODIF' => $date->toString('YYYY-MM-dd HH:mm:ss'),
$line.'IDPRODUCT' => $idProduct,
$line.'POINTFIDELITE' => $pointFidelite
);
$dataChild = array (
'REFERENCE' => $filter->filter($reference),
'POIDS' => $filter->filter($poids),
'DESIGNATION' => $designation,
'PRIX' => $filter->filter($prixNormal),
'ETATSTOCK' => $filter->filter($etatstock),
'QUANTITYMIN' => $filter->filter($quantiteMin),
'isDEVIS' => $isDevisPrice,
'isFRANCODENIED' => $isFrancoDenied,
'IMAGEPROMO' => $filter->filter($imagePromo),
'DATEMODIF' => $date->toString('YYYY-MM-dd HH:mm:ss'),
'IDPRODUCT' => $idProduct ,
'POINTFIDELITE' => $pointFidelite
);
if ($validator->isValid($dataChild['REFERENCE']) &&
$validator2->isValid($dataChild['PRIX'])&&
$validator->isValid($dataChild['DESIGNATION'])
) {
try {
$productChild = new ProductChild();
$productChild->update($dataChild, 'ID = '.$idChild);
$productChildOption = new ProductChildOption();
foreach ($listOption as $option) {
$dataOption = array (
'IDPRODUCTCHILD' => $idChild,
'IDOPTION' => $option,
'VALUE' => $optionsValues['option'.$option]
);
$isOk = $productChildOption->update($dataOption,'IDPRODUCTCHILD = '.$idChild.' AND IDOPTION = '.$option);
if (!$isOk) {
$productChildOption->delete('IDPRODUCTCHILD = '.$idChild.' AND IDOPTION = '.$option);
$productChildOption->insert($dataOption);
}
}
$this->view->messageSuccess = "Le produit a �t� modifi�";
$this->indexproductById($idProduct);
return true;
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La r�f�rence existe d�ja";
$this->view->populateChild = $dataChildReturn;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateChild = $dataChildReturn;
}
return false;
}
public function delchildAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('idchild')) {
$idchild = (int)$this->_request->getParam('idchild');
$id = (int)$this->_request->getParam('id');
if ($idchild > 0 && $id > 0) {
try {
$childFTFDS = new ProductChildFTFDS();
$child = $childFTFDS->fetchRow('ID_CHILD = '.$idchild);
if (!$child) {
$productChild = new ProductChild();
$productChild->delete('ID = '.$idchild);
$productChildOption = new ProductChildOption();
$productChildOption->delete('IDPRODUCTCHILD = '.$idchild);
$this->view->messageSuccess = "Le produit a �t� supprim�";
} else {
$this->view->messageError = "Un document est associ�e a ce produit, vous devez la supprimer avant de supprimer le produit";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
public function addchildAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//valideurs pour les chaines
$validator2 = new Zend_Validate();
$validator2 -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$date = new Zend_Date();
$adminNamespace = $this->getSession();
$isDevisPrice = 1;
if (isset($params['devisprice']) && $params['devisprice']) {
$isDevisPrice = 0;
}
$quantiteMin = (int)$params['quantiteMin'];
if ($quantiteMin == 0) {
$quantiteMin = 1;
}
$dataChild = array (
'REFERENCE' => $filter->filter($params['reference']),
'DESIGNATION' => $filter->filter($params['designation']),
'PRIX' => $filter->filter($params['prixNormal']),
'ETATSTOCK' => $filter->filter($params['etatstock']),
'QUANTITYMIN' => $filter->filter($quantiteMin),
'isDEVIS' => $isDevisPrice,
'IMAGEPROMO' => $filter->filter($params['imagePromo']),
'DATEMODIF' => $date->toString('YYYY-MM-dd HH:mm:ss'),
'IDPRODUCT' => (int)$this->_request->getParam('id')
);
$listOption = unserialize($params['listOption']);
if ($validator->isValid($dataChild['REFERENCE']) &&
$validator2->isValid($dataChild['PRIX'])&&
$validator->isValid($dataChild['DESIGNATION'])
) {
try {
$productChild = new ProductChild();
$productChild->insert($dataChild);
$lastid = $productChild->getAdapter()->lastInsertId();
$productChildOption = new ProductChildOption();
foreach ($listOption as $option) {
$dataOption = array (
'IDPRODUCTCHILD' => $lastid,
'IDOPTION' => $option,
'VALUE' => $params['option'.$option]
);
$productChildOption->insert($dataOption);
}
$this->view->messageSuccess = "Le produit a �t� ajout�";
} catch (Zend_Exception $e) {
$this->view->messageError = "La r�f�rence existe d�j�";
$this->log($e->getMessage(),'err');
$this->view->populateChild = $dataChild;
$this->_forward('/edit');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateChild = $dataChild;
}
}
$this->_forward('/edit');
}
public function addchildsAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//get the form params
$params = $this->_request->getPost();
for ($index = 0; $index < 2; $index++) {
try {
if (isset($params[$index."reference"]) && !empty($params[$index."reference"]) &&
isset($params[$index."designation"]) && !empty($params[$index."designation"])
) {
$optionsValues = array();
$listOption = unserialize($params['listOption']);
foreach ($listOption as $option) {
$optionsValues['option'.$option] = $params[$index."option".$option];
}
$isDevisPrice = 1;
if (isset($params[$index.'devisprice']) && $params[$index.'devisprice']) {
$isDevisPrice = 0;
}
$this->addSingleChild($index, $isDevisPrice,
$params[$index.'quantiteMin'],
$params[$index.'reference'],
$params[$index.'poids'],
$params[$index.'designation'],
$params[$index.'prixNormal'],
$params[$index.'etatstock'],
$params[$index.'imagePromo'],
$listOption,
$optionsValues,
(int)$this->_request->getParam('id'));
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "V�rifier les param�tres";
}
}
}
$this->_forward('/edit');
}
private function addSingleChild($line, $isDevisPrice, $quantity, $reference, $poids, $designation, $prixNormal, $etatstock, $imagePromo, $listOption, $optionsValues, $idProduct) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//valideurs pour les chaines
$validator2 = new Zend_Validate();
$validator2 -> addValidator(new Zend_Validate_NotEmpty());
$quantiteMin = (int)$quantity;
if ($quantiteMin == 0) {
$quantiteMin = 1;
}
$date = new Zend_Date();
$adminNamespace = $this->getSession();
$dataChildReturn = array (
$line.'REFERENCE' => $filter->filter($reference),
$line.'POIDS' => $filter->filter($poids),
$line.'DESIGNATION' => $filter->filter($designation),
$line.'PRIX' => $filter->filter($prixNormal),
$line.'ETATSTOCK' => $filter->filter($etatstock),
$line.'QUANTITYMIN' => $filter->filter($quantiteMin),
$line.'isDEVIS' => $isDevisPrice,
$line.'IMAGEPROMO' => $filter->filter($imagePromo),
$line.'DATEMODIF' => $date->toString('YYYY-MM-dd HH:mm:ss'),
$line.'IDPRODUCT' => $idProduct
);
$poids = $filter->filter($poids);
if (empty($poids)) { $poids = 0; }
$quantiteMin = $filter->filter($quantiteMin);
if (empty($quantiteMin)) { $quantiteMin = 1; }
$imagePromo = $filter->filter($imagePromo);
if (empty($imagePromo)) { $imagePromo = 0; }
$dataChild = array (
'REFERENCE' => $filter->filter($reference),
'POIDS' => $poids,
'DESIGNATION' => $filter->filter($designation),
'PRIX' => $filter->filter($prixNormal),
'ETATSTOCK' => $filter->filter($etatstock),
'QUANTITYMIN' => $quantiteMin,
'isDEVIS' => $isDevisPrice,
'IMAGEPROMO' => $imagePromo,
'DATEMODIF' => $date->toString('YYYY-MM-dd HH:mm:ss'),
'IDPRODUCT' => $idProduct
);
if ($validator->isValid($dataChild['REFERENCE']) &&
$validator2->isValid($dataChild['PRIX'])&&
$validator->isValid($dataChild['DESIGNATION'])
) {
try {
$productChild = new ProductChild();
if (!$productChild->isChildReferenceExist($dataChild['REFERENCE'])){
$productChild->insert($dataChild);
$lastid = $productChild->getAdapter()->lastInsertId();
$productChildOption = new ProductChildOption();
foreach ($listOption as $option) {
$dataOption = array (
'IDPRODUCTCHILD' => $lastid,
'IDOPTION' => $option,
'VALUE' => $optionsValues['option'.$option]
);
$productChildOption->insert($dataOption);
}
$this->view->messageSuccess = "Le produit a �t� ajout�";
return true;
} else {
$this->view->populateChild = $dataChildReturn;
$this->view->messageError = "La r�f�rence existe d�ja";
return false;
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La r�f�rence existe d�ja";
$this->view->populateChild = $dataChildReturn;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
foreach ($validator2->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateChild = $dataChildReturn;
}
return false;
}
public function addproductoptionAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
$params = $this->_request->getPost();
$data = array (
'IDPRODUCT' => (int)$this->_request->getParam('id'),
'IDOPTION' => $params['idoption']
);
try {
$product = new Product();
$sql = 'SELECT p.NOM
FROM product p
LEFT JOIN product_option AS po ON po.IDPRODUCT = p.ID
WHERE p.ID = '.$data['IDPRODUCT'].'
AND po.IDOPTION = '.$data['IDOPTION'];
$isExistOption = $product->getAdapter()->fetchRow($sql);
if (!$isExistOption) {
$productOption = new ProductOption();
$productOption->insert($data);
$this->view->messageSuccess = "L'option a �t� ajout�e";
} else {
$this->view->messageError = "L'option existe d�ja";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
public function delproductoptionAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
$adminNamespace = $this->getSession();
if($this->_request->getParam('idopt')) {
$idopt = (int)$this->_request->getParam('idopt');
$id = (int)$this->_request->getParam('id');
if ($idopt > 0 && $id > 0) {
try {
$productOption = new ProductOption();
$productChildOption = new ProductChildOption();
$productOption->delete('IDOPTION = '.$idopt.' AND IDPRODUCT = '.$id);
$sql = "
DELETE pco
FROM productchild_option AS pco
LEFT JOIN productchild AS pc ON pc.ID = pco.IDPRODUCTCHILD
WHERE pco.IDOPTION = ".$idopt."
AND pc.IDPRODUCT = ".$id;
$productChildOption->getAdapter()->query($sql);
$this->view->messageSuccess = "L'option a �t� supprim�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
public function optionprofilAction() {
$this->view->titlePage = "Listing des Profils d'options";
if ($this->_request->isPost() && (int)$this->_request->getParam('id') ==0) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$options = $params['profilOptions'];
$optionValues = "";
foreach ($options as $idOption) {
$optionValues .= $idOption.";";
}
$data = array (
'NOM' => $filter->filter($params['nom']),
'OPTS' => $optionValues
);
if ($validator->isValid($data['NOM'])) {
try {
$optionProfil = new OptionProfil();
$optionProfil->insert($data);
$this->view->messageSuccess = "Le profil a �t� ajout�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le profil existe d�ja";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$option = new Option();
$listOptions = $option->select()->order('NOM ASC')->query()->fetchAll();
$this->view->listoption = $listOptions;
$optionProfil = new OptionProfil();
$this->view->listprofils = $optionProfil->getProfils();
}
public function optionprofildelAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$optionProfil = new OptionProfil();
$optionProfil->delete('ID = '.$id);
$this->view->messageSuccess = "Le profil a �t� supprim�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
$this->_forward('/optionprofil');
}
}
}
$this->_forward('/optionprofil');
}
public function optionAction() {
$this->view->titlePage = "Gestion des caract�ristiques du produit";
$this->view->currentMenu = "Option";
if ($this->_request->isPost() && (int)$this->_request->getParam('id') ==0) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$data = array (
'NOM' => $filter->filter($params['nom'])
);
if ($validator->isValid($data['NOM'])) {
try {
$option = new Option();
$option->insert($data);
$this->view->messageSuccess = "La caract�ristique a �t� ajout�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La caract�ristique existe d�ja";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$option = new Option();
$this->view->listoption = $option->select()->order('NOM ASC')->query()->fetchAll();
}
public function optioneditAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$data = array (
'NOM' => $filter->filter($params['nom']),
'ID' => $filter->filter($params['id'])
);
if ($validator->isValid($data['NOM'])
) {
try {
$option = new Option();
$option->update($data, 'ID = '.$data['ID']);
$this->view->messageSuccess = "La caract�ristique a �t� modifi�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La caract�ristique existe d�j�";
$this->_forward('option');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('option');
}
public function optiondelAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$product = new Product();
$sql = 'SELECT p.NOM
FROM product p
LEFT JOIN productchild AS pc ON pc.IDPRODUCT = p.ID
LEFT JOIN productchild_option AS pco ON pco.IDPRODUCTCHILD = pc.ID
WHERE pco.IDOPTION = '.$id ;
$isExistProduct = $product->getAdapter()->fetchRow($sql);
if (!$isExistProduct) {
$option = new Option();
$option->delete('ID = '.$id);
$this->view->messageSuccess = "La caract�ristique a �t� supprim�e";
} else {
$this->view->messageError = "La caract�ristique est utilis�e par : <b>".$isExistProduct['NOM']."</b>";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
$this->_forward('/option');
}
}
}
$this->_forward('/option');
}
public function editftfdsAction() {
$params = $this->_request->getPost();
if(!empty($params['idchild_ftfds']) && !empty($_FILES['file_ftfds']) && !empty($_FILES['file_ftfds']['name'])) {
$nomOrigine = $_FILES['file_ftfds']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("pdf");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
// incluant l'heure a la seconde pres
$repertoireDestination = 'items/ftfds/';
$this->checkDirectoryExist($repertoireDestination);
$nomDestination = $params['idchild_ftfds'].".".$extensionFichier;
if (move_uploaded_file($_FILES["file_ftfds"]["tmp_name"],$repertoireDestination.$nomDestination)) {
try {
$childFTFDS = new ProductChildFTFDS();
$data = array (
'URL' => $repertoireDestination.$nomDestination,
'ID_CHILD' => $params['idchild_ftfds']
);
$childFTFDS->insert($data);
$this->view->messageSuccess = "Le document a �t� ajout�e ";
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
}
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
} else {
$this->view->messageError = "Veuillez s�lectionner un document au format pdf";
}
$this->_forward('/edit');
}
public function delftfdsAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('idchild')) {
$idchild = (int)$this->_request->getParam('idchild');
if ($idchild > 0) {
try {
$childFTFDS = new ProductChildFTFDS();
$child = $childFTFDS->fetchRow('ID_CHILD = '.$idchild);
$childFTFDS->delete('ID_CHILD = '.$idchild);
unlink($child['URL']);
$this->view->messageSuccess = "Le document a �t� supprim�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
public function editdocAction() {
$params = $this->_request->getPost();
if(!empty($params['docname_product']) && !empty($_FILES['file_doc']) && !empty($_FILES['file_doc']['name'])) {
$nomOrigine = $_FILES['file_doc']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("pdf");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
// incluant l'heure a la seconde pres
$repertoireDestination = 'items/doc/';
$this->checkDirectoryExist($repertoireDestination);
$nomDestination = $params['docid_product'].".".$extensionFichier;
if (move_uploaded_file($_FILES["file_doc"]["tmp_name"],$repertoireDestination.$nomDestination)) {
try {
$product = new Product();
$data = array (
'DOCURL' => $repertoireDestination.$nomDestination,
'DOCNAME' => $params['docname_product']
);
$product->update($data, "ID = ".$params['docid_product']);
$this->view->messageSuccess = "Le document a �t� ajout� ";
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
}
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
} else {
$this->view->messageError = "Veuillez s�lectionner un document au format pdf";
}
$this->_forward('/edit');
}
public function deldocAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$product = new Product();
$row = $product->fetchRow('ID = '.$id)->toArray();
$docurl = $row['DOCURL'];
unlink($docurl);
$data = array (
'DOCURL' => "",
'DOCNAME' => ""
);
$product->update($data, "ID = ".$id);
$this->view->messageSuccess = "Le document a �t� supprim�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
public function livraisonAction() {
$this->view->titlePage = "Configuration de la livraison";
$livraison_type = new LivraisonType();
$this->view->livraisontypes = $livraison_type->getTypes();
$livraison_poids = new LivraisonPoids();
$this->view->livraisonpoids = $livraison_poids->getLists();
}
public function addlivraisontypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'NOM' => $filter->filter($params['livraison_nom']),
'CMDFRANCO' => $filter->filter($params['livraison_franco'])
);
if ($validator->isValid($data['NOM'])
) {
try {
$livraison_type = new LivraisonType();
$livraison_type->insert($data);
$this->view->messageSuccess = "Le type de livraison a �t� ajout�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le type de livraison existe d�ja";
$this->_forward('/livraison');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/livraison');
}
public function dellivraisontypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$livraison_type = new LivraisonType();
$livraison_poids = new LivraisonPoids();
$livraison_type->delete("ID = ".$id);
$livraison_poids->delete("TYPE = ".$id);
$this->view->messageSuccess = "Le type de livraison a �t� supprim�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/livraison');
}
public function editlivraisontypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'NOM' => $filter->filter($params['livraison_nom']),
'CMDFRANCO' => $filter->filter($params['livraison_franco'])
);
if ($validator->isValid($data['NOM'])
) {
try {
$livraison_type = new LivraisonType();
$livraison_type->update($data, "ID = ".$params['livraison_id']);
$this->view->messageSuccess = "Le type de livraison a �t� modifi�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le type de livraison n'a pas �t� modifi�";
$this->_forward('/livraison');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/livraison');
}
public function addlivraisonpoidsAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
if (isset($params['livraison_poids_type'])) {
$data = array (
'TO' => floatval($params['livraison_poids_to']),
'FROM' => floatval($params['livraison_poids_from']),
'TYPE' => floatval($params['livraison_poids_type']),
'PRICE' => floatval($params['livraison_poids_price'])
);
if ($data['TO'] > 0 && $data['TYPE'] > 0) {
try {
$livraison_poids = new LivraisonPoids();
$livraison_poids->insert($data);
$this->view->messageSuccess = "Le poids de la livraison a �t� ajout�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le poids de la livraison n'a pas �t� ajout�";
$this->_forward('/livraison');
}
} else {
$this->view->messageError = "Le poids de la livraison n'a pas �t� ajout�";
$this->_forward('/livraison');
}
}
}
$this->_forward('/livraison');
}
public function editlivraisonpoidsAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'TO' => floatval($params['livraison_poids_to']),
'FROM' => floatval($params['livraison_poids_from']),
'TYPE' => floatval($params['livraison_poids_type']),
'PRICE' => floatval($params['livraison_poids_price'])
);
if ($data['TO'] > 0 && $data['TYPE'] > 0 ) {
try {
$livraison_poids = new LivraisonPoids();
$livraison_poids->update($data, "ID = ".$params['livraison_poids_id']);
$this->view->messageSuccess = "Le poids de la livraison a �t� modifi�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le poids de la livraison n'a pas �t� modifi�";
$this->_forward('/livraison');
}
} else {
$this->view->messageError = "Le poids de la livraison n'a pas �t� modifi�";
$this->_forward('/livraison');
}
}
$this->_forward('/livraison');
}
public function dellivraisonpoidsAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$livraison_poids = new LivraisonPoids();
$livraison_poids->delete("ID = ".$id);
$this->view->messageSuccess = "Le poids de la livraison a �t� supprim�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/livraison');
}
public function livraisoncatAction(){
$this->view->titlePage = "Configuration g�n�ralis�e du poids";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//get the form params
try {
$params = $this->_request->getPost();
if (isset($params["livraison_poids_id"]) && !empty($params["livraison_poids_id"])) {
$listCatId = array();
$listCatId = $params['livraison_poids_id'];
$productChild = new ProductChild();
foreach ($listCatId as $catId) {
if (isset($params["livraison_poids_".$catId]) && !empty($params["livraison_poids_".$catId]) && $params["livraison_poids_".$catId] > 0) {
$sql = "UPDATE productchild, product SET productchild.poids=".floatval($params["livraison_poids_".$catId])." WHERE productchild.idproduct=product.id AND product.idcategory=".$catId;
$productChild->getAdapter()->query($sql);
}
}
$this->view->messageSuccess = "Les produits ont �t� mis a jour";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
public function keywordsengineAction() {
$this->view->titlePage = "Configuration des mots cl�s";
$keyword = new KeyWord();
$listkeywords = $keyword->getLists();
$this->setPaginator($listkeywords, $this->_getParam('page',1), 50);
}
public function keywordsengineresetAction() {
try {
$product = new Product();
$sql = "SELECT KEYWORDS FROM product" ;
$keyProducts = $product->getAdapter()->fetchAll($sql);
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StringToLower());
$keys = array();
foreach ($keyProducts as $row) {
$keyArray = preg_split("/[\s]*[,][\s]*/", $row['KEYWORDS']);
for ($index = 0; $index < sizeof($keyArray); $index++) {
$keyTemp = $filter->filter($keyArray[$index]);
if (!in_array($keyTemp, $keys) && !empty($keyTemp)) {
array_push($keys, $keyTemp);
}
}
}
$keyword = new KeyWord();
for ($index = 0; $index < sizeof($keys); $index++) {
try {
$data = array( "KEYWORD" => $keys[$index] );
$keyword->insert($data);
} catch (Zend_Exception $e) { }
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$this->_forward('/keywordsengine');
}
public function addkeywordsengineAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringToLower())
->addFilter(new Zend_Filter_CustomAlnum(array('allowwhitespace' => true)));
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
if (isset($params['keyword']) && $validator->isValid($params['keyword'])) {
$data = array (
'KEYWORD' => $filter->filter($params['keyword'])
);
$keyword = new KeyWord();
if (!$keyword->isExist($data['KEYWORD'])) {
try {
$keyword->insert($data);
$this->view->messageSuccess = "Le mot cl� a �t� ajout�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le mot cl� n'a pas �t� ajout�";
}
} else {
$this->view->messageError = "Le mot cl� existe";
}
} else {
$this->view->messageError = "Le mot cl� n'a pas �t� ajout�";
}
}
$this->_forward('/keywordsengine');
}
public function editkeywordsengineAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringToLower())
->addFilter(new Zend_Filter_CustomAlnum(array('allowwhitespace' => true)));
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$data = array (
'KEYWORD' => $filter->filter($params['keyword'])
);
try {
$keyword = new KeyWord();
$result = $keyword->update($data, "ID = ".$params['keyword_id']);
if ($result) {
$this->view->messageSuccess = "Le mot cl� a �t� modifi�";
} else {
$this->view->messageError = "Le mot cl� existe";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le mot cl� n'a pas �t� modifi�";
}
}
$this->_forward('/keywordsengine');
}
public function delkeywordsengineAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$keyword = new KeyWord();
$keyword->delete("ID = ".$id);
$this->view->messageSuccess = "Le mot cl� a �t� supprim�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/keywordsengine');
}
public function ajaxautocompletekeywordAction() {
$result = array();
try {
if ($this->getRequest()->isPost()) {
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringToLower())
->addFilter(new Zend_Filter_CustomAlnum(array('allowwhitespace' => true)));
$keyword = new KeyWord();
$key = $filter->filter(utf8_decode($this->getRequest()->getPost('search')));
$result = $keyword->findByKeyword($key);
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$this->view->messageSuccess = serialize($result);
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxvalue');
}
public function ajaxautocompletekeywordinsertAction() {
$currentKeywords = "";
$idproduct = 0;
if ($this->getRequest()->isPost()) {
try {
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringToLower())
->addFilter(new Zend_Filter_CustomAlnum(array('allowwhitespace' => true)));
$key = $filter->filter(utf8_decode($this->getRequest()->getPost('search')));
$idproduct = (int)$this->getRequest()->getPost('idproduct');
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
if ($validator->isValid($key) && $idproduct > 0) {
$product = new Product();
$row = $product->fetchRow('ID = '.$idproduct)->toArray();
if (empty($row['KEYWORDS'])) {
$currentKeywords = $key;
} else {
$currentKeywords = $row['KEYWORDS'].",".$key;
}
$data = array( "KEYWORDS" => $currentKeywords);
$product->update($data, 'ID = '.$idproduct);
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');}
}
if (!empty($currentKeywords)) {
$this->view->messageSuccess = $currentKeywords;
} else {
if ($idproduct > 0) {
$product = new Product();
$row = $product->fetchRow('ID = '.$idproduct)->toArray();
$this->view->messageSuccess = $row['KEYWORDS'];
}
}
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxvalue');
}
public function autocompletekeywordaddAction() {
$currentKeywords = "";
$idproduct = 0;
if ($this->getRequest()->isPost()) {
try {
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringToLower())
->addFilter(new Zend_Filter_CustomAlnum(array('allowwhitespace' => true)));
$key = $filter->filter($this->getRequest()->getPost('keywords_list'));
$idproduct = (int)$this->getRequest()->getPost('id');
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
if ($validator->isValid($key) && $idproduct > 0) {
$keyword = new KeyWord();
if (!$keyword->isExist($key)) {
$data = array( "KEYWORD" => $key);
$keyword->insert($data);
}
$product = new Product();
$row = $product->fetchRow('ID = '.$idproduct)->toArray();
if (empty($row['KEYWORDS'])) {
$currentKeywords = $key;
} else {
$currentKeywords = $row['KEYWORDS'].",".$key;
}
$data = array( "KEYWORDS" => $currentKeywords);
$product->update($data, 'ID = '.$idproduct);
$this->view->messageSuccess = "Le mot cl� a �t� ajout�";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le mot cl� n'a pas �t� ajout�";
}
}
$this->_forward('/edit');
}
public function ajaxproductaccessoirelistbycatAction() {
try {
if ($this->getRequest()->isPost()) {
$idcat = (int) $this->getRequest()->getPost('idcategory');
$idcurrentproduct = (int) $this->getRequest()->getPost('idproduct');
$product = new Product();
$listproducts = $product->getProductsByIdCategory($idcat, 'NOM ASC');
$this->view->listProducts = $listproducts;
$this->view->currentProduct = $idcurrentproduct;
$productAccessoire = new ProductAccessoire();
$this->view->listAccessoires = $productAccessoire->getAccessoiresByProductID($idcurrentproduct, 'pa.REFACCESSOIRE ASC');;
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxaccessoireproductlist');
}
public function addproductaccessoireAction() {
$productAccessoire = new ProductAccessoire();
$productChild = new ProductChild();
try {
if ($this->getRequest()->isPost()) {
$params = $this->_request->getPost();
$idproduct = (int) $params['id'];
$refaccessoire = $params['reference_acc'];
if ($idproduct > 0 && !empty($refaccessoire) ) {
if ($productChild->isChildReferenceExist($params['reference_acc'])) {
$isOk = $productAccessoire->insertAccessoire($idproduct, $refaccessoire);
if ($isOk) {
$this->view->messageSuccess = "L'accessoire a �t� ajout�";
} else {
$this->view->messageError = "L'accessoire n'a pas �t� ajout�, il est d�j� pr�sent pour ce produit";
}
} else {
$this->view->messageError = "La r�f�rence n'existe pas";
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$this->_forward('/edit');
}
public function ajaxdelproductaccessoireAction() {
$productAccessoire = new ProductAccessoire();
try {
if ($this->getRequest()->isPost()) {
$params = $this->_request->getPost();
$idAccessoire = (int) $params['idAccessoire'];
$idproduct = (int) $params['idproduct'];
if ($idAccessoire > 0 ) {
$productAccessoire->deleteAccessoire($idAccessoire);
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$listAccessoires = $productAccessoire->getAccessoiresByProductID($idproduct, 'pa.REFACCESSOIRE ASC');
$this->view->listAccessoires = $listAccessoires ;
$this->view->currentProduct = $idproduct;
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxaccessoirelist');
}
public function ajaxproductannexelistbycatAction() {
try {
if ($this->getRequest()->isPost()) {
$idcat = (int) $this->getRequest()->getPost('idcategory');
$idcurrentproduct = (int) $this->getRequest()->getPost('idproduct');
$product = new Product();
$listproducts = $product->getProductsByIdCategory($idcat, 'NOM ASC');
$this->view->listProducts = $listproducts;
$this->view->currentProduct = $idcurrentproduct;
$productAnnexe = new ProductAnnexe();
$this->view->listAnnexes = $productAnnexe->getAnnexesByProductID($idcurrentproduct, 'NOM ASC');;
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxannexeproductlist');
}
public function ajaxaddproductannexeAction() {
$productAnnexe = new ProductAnnexe();
try {
if ($this->getRequest()->isPost()) {
$params = $this->_request->getPost();
$idproduct = (int) $params['idproduct'];
$idannexe = (int) $params['idannexe'];
if ($idproduct > 0 && $idannexe > 0 && ($idproduct != $idannexe)) {
$productAnnexe->insertAnnexe($idproduct, $idannexe);
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$listproducts = $productAnnexe->getAnnexesByProductID($idproduct, 'NOM ASC');
$this->view->listProducts = $listproducts;
$this->view->listAnnexes = $listproducts;
$this->view->currentProduct = $idproduct;
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxannexeproductlist');
}
public function ajaxdelproductannexeAction() {
$productAnnexe = new ProductAnnexe();
try {
if ($this->getRequest()->isPost()) {
$params = $this->_request->getPost();
$idproduct = (int) $params['idproduct'];
$idannexe = (int) $params['idannexe'];
if ($idproduct > 0 && $idannexe > 0 && ($idproduct != $idannexe)) {
$productAnnexe->deleteAnnexe($idproduct, $idannexe);
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$listproducts = $productAnnexe->getAnnexesByProductID($idproduct, 'NOM ASC');
$this->view->listProducts = $listproducts;
$this->view->listAnnexes = $listproducts;
$this->view->currentProduct = $idproduct;
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxannexeproductlist');
}
public function editnavheaderAction () {
try {
if ($this->getRequest()->isPost()) {
$params = $this->_request->getPost();
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
$filter2 = new Zend_Filter();
$filter2->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringToLower())
->addFilter(new Zend_Filter_CustomAlnum(array('allowwhitespace' => true)));
$key = $params['keywords_list'];
$keyToAdd = "";
$keyArray = explode(",", $key);
$keyword = new KeyWord();
for ($index = 0; $index < sizeof($keyArray); $index++) {
$keyTemp = $filter2->filter($keyArray[$index]);
$keyTemp = $filter->filter($keyTemp);
if (!empty($keyTemp)) {
if (empty($keyToAdd)) {
$keyToAdd = $keyTemp;
} else {
$keyToAdd .=", ".$keyTemp;
}
if (!$keyword->isExist($keyTemp)) {
$data = array( "KEYWORD" => $keyTemp);
$keyword->insert($data);
}
}
}
$data = array (
'NAVTITRE' => $filter->filter($params['navtitre']),
'NAVDESC' => $filter->filter($params['navdesc']),
'KEYWORDS' => $keyToAdd
);
$product = new Product();
$product->update($data, 'ID = '.(int) $params['id']);
$this->indexproductById((int) $params['id']);
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
}
$this->_forward('/edit');
}
public function editcustomnavnomAction() {
try {
if ($this->getRequest()->isPost()) {
$params = $this->_request->getPost();
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$data = array (
'NAVNOM' => $this->verifyNavigationString($filter->filter($params['navnom']), $params['nom'], ''),
'CUSTOM_NAVNOM1' => $filter->filter($params['navnom_custom1']),
'CUSTOM_NAVNOM2' => $filter->filter($params['navnom_custom2']),
'CUSTOM_NAVNOM3' => $filter->filter($params['navnom_custom3'])
);
if ($validator->isValid($data['NAVNOM'])) {
for ($index = 1; $index < 4; $index++) {
if (!empty($data['CUSTOM_NAVNOM'.$index])) {
$data['CUSTOM_NAVNOM'.$index] = $this->verifyNavigationString($data['CUSTOM_NAVNOM'.$index], $data['CUSTOM_NAVNOM'.$index], '');
}
}
$product = new Product();
$product->update($data, 'ID = '.(int) $params['id']);
$this->indexproductById((int) $params['id']);
$this->view->messageSuccess = "Le nom de navigation a �t� modifi�";
} else {
$this->view->messageError = "Le nom de navigation n'a pas �t� modifi�";
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
$this->view->messageError = "Le nom de navigation n'a pas �t� modifi�";
}
$this->_forward('/edit');
}
public function addchildqteprixAction() {
try {
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
$params = $this->_request->getPost();
$min = (int) $params['min'];
$max = (int) $params['max'];
$prix = $filter->filter($params['prix']);
$item_id = (int) $params['item_id'];
if (isset($params['maxend'])) {
$maxend = $params['maxend'];
if ($maxend) { $max = 999999999; }
}
if ($min > 0 && $max > 0 && $prix > 0 && $item_id > 0) {
if ($min < $max) {
$dataQte = array (
'MIN' => $min,
'MAX' => $max,
'PRIX' => $prix,
'IDPRODUCTCHILD' => $item_id
);
$productChildQte = new ProductChildQte();
$productChildQte->insert($dataQte);
$this->view->messageSuccess = "Le prix d�gressif a �t� ajout�";
} else { $this->view->messageError = "V�rifier les quantit�s"; }
} else { $this->view->messageError = "V�rifier les param�tres"; }
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
$this->view->messageError = "Le prix d�gressif n'a pas �t� ajout�";
}
$this->_forward('/edit');
}
public function delchildqteprixAction() {
try {
if($this->_request->getParam('item_id')) {
$id = (int)$this->_request->getParam('item_id');
if ($id > 0) {
$productChildQte = new ProductChildQte();
$isDeleted = $productChildQte->delete('ID = '.$id);
if ($isDeleted) {
$this->view->messageSuccess = "Le prix d�gressif a �t� supprim�";
} else {
$this->view->messageError = "Le prix d�gressif n'a pas �t� supprim�";
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
$this->view->messageError = "Le prix d�gressif n'a pas �t� supprim�";
}
$this->_forward('/edit');
}
public function editchildqteprixactivationAction() {
try {
if ($this->_request->isPost()) {
$params = $this->_request->getPost();
$isActive = 0;
if (isset($params['activateItemPrix'])) { $isActive = 1; }
$id = (int)$params['id'];
if ($id > 0) {
$data = array (
'isQTEPRIXACTIVE' => $isActive
);
$product = new Product();
$isUpdated = $product->update($data, 'ID = '.$id);
if ($isUpdated > 0) {
$this->view->messageSuccess = "Le prix d�gressif a �t� modifi�";
} else {
$this->view->messageError = "Le prix d�gressif n'a pas �t� modifi�";
}
$this->indexproductById($id);
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
$this->view->messageError = "Le prix d�gressif n'a pas �t� modifi�";
}
$this->_forward('/edit');
}
public function addcaracteristiquelistAction() {
try {
if ($this->_request->isPost()) {
$params = $this->_request->getPost();
$idoption = (int)$params['idoption'];
$id = (int)$params['id'];
if ($idoption > 0 && $id > 0) {
$data = array (
'ONSELECT_IDOPTION' => $idoption
);
$product = new Product();
$isUpdated = $product->update($data, 'ID = '.$id);
if ($isUpdated > 0) {
$this->view->messageSuccess = "La liste des caract�ristiques a �t� modifi�";
} else {
$this->view->messageError = "La liste des caract�ristiques n'a pas �t� modifi�";
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
$this->view->messageError = "La liste des caract�ristiques n'a pas �t� modifi�";
}
$this->_forward('/edit');
}
public function delcaracteristiquelistAction() {
try {
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
$data = array (
'ONSELECT_IDOPTION' => 0
);
$product = new Product();
$isUpdated = $product->update($data, 'ID = '.$id);
if ($isUpdated > 0) {
$this->view->messageSuccess = "La liste des caract�ristiques a �t� modifi�";
} else {
$this->view->messageError = "La liste des caract�ristiques n'a pas �t� modifi�";
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(), 'err');
$this->view->messageError = "La liste des caract�ristiques n'a pas �t� modifi�";
}
$this->_forward('/edit');
}
}
?>PK �0H[�C�� � ErrorController.phpnu &1i� <?php
class Backoffice_ErrorController extends Zend_Controller_Action
{
public function errorAction()
{
$errors = $this->_getParam('error_handler');
$this->initLog();
$this->log("Une erreure est survenue : ".$errors,'crit');
$this->_redirect('/backoffice');
}
private function initLog() {
$registry = Zend_Registry::getInstance();
$loggerAdmin = $registry->get('loggerAdmin');
$controller = Zend_Controller_Front::getInstance()->getRequest();
$loggerAdmin->setEventItem('controller', $controller->getControllerName().'::'.$controller->getActionName());
$registry->set('loggerAdmin', $loggerAdmin);
}
private function log($message , $level) {
$loggerAdmin = Zend_Registry::get('loggerAdmin');
if ($level == 'info') {
$loggerAdmin->info($message);
} elseif ($level == 'err') {
$loggerAdmin->err($message);
} elseif ($level == 'warn') {
$loggerAdmin->warn($message);
} elseif ($level == 'crit') {
$loggerAdmin->crit($message);
}
}
}
?>PK �0H[�i!1w 1w MaintenanceController.phpnu &1i� <?php
class Backoffice_MaintenanceController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Scripts";
$this->isConnectedWithRole('isMaintenance');
}
public function indexAction()
{
}
/*
* Image de produits - Redimmensionnement de l'image
*/
public function resizepictureAction()
{
try {
echo "------------ PRODUITS ------------<br />";
for($i = 0; $i < 500; $i++) {
$dirname = 'items/product/'.$i;
$this->resizepictureofdirectory($dirname);
}
echo "------------ CATEGORIES ------------<br />";
for($i = 0; $i < 500; $i++) {
$dirname = 'items/category/'.$i;
$this->resizepictureofdirectory($dirname);
}
echo "------------ CATEGORIES SUBSIDIAIRES ------------<br />";
for($i = 0; $i < 500; $i++) {
$dirname = 'items/category2/'.$i;
$this->resizepictureofdirectory($dirname);
}
echo "------------ FOURNISSEURS ------------<br />";
$dirname = 'items/supplier';
$this->resizepictureofdirectory($dirname);
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
private function resizepictureofdirectory($dirname)
{
$maxwidth = $this->FeaturePictureResizeWidth;
$maxheight = $this->FeaturePictureResizeHeight;
if (is_dir($dirname)) {
$dir_handle = opendir($dirname);
if (!isset($dir_handle)) {
return false;
}
while($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
$fileoriginal = $dirname."/".$file;
if (is_dir($fileoriginal)) {
$this->resizepictureofdirectory($fileoriginal);
} else {
$info = getimagesize($fileoriginal) ;
list($width_old, $height_old) = $info;
if ($width_old > $maxwidth || $height_old > $maxheight) {
echo "Redimensionnement de l'image : ".$fileoriginal." (Width : Old - ".$width_old." Max - ".$maxwidth.", Height : Old - ".$height_old." Max - ".$maxheight.")<br />";
Utils_Tool::smart_resize_image($fileoriginal , null, $maxwidth , $maxheight , true , $fileoriginal , true , false ,50 );
}
}
}
}
}
}
/*
* Image de produits - Renommage des nom de type date
*/
function cleanproductimagenamedeterminename($row){
$newName = "";
if (empty($newName) && !empty($row['STRING1']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($row['STRING1']).".".$extension)) {
$newName = $this->generateNavigationString($row['STRING1']);
} else if (empty($newName) && !empty($row['STRING2']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($row['STRING2']).".".$extension)) {
$newName = $this->generateNavigationString($row['STRING2']);
} else if (empty($newName) && !empty($row['CUSTOM_NAVNOM1']) && !file_exists($repertoireDestination."/".$row['CUSTOM_NAVNOM1'].".".$extension)) {
$newName = $row['CUSTOM_NAVNOM1'];
} else if (empty($newName) && !empty($row['NAVNOM']) && !file_exists($repertoireDestination."/".$row['NAVNOM'].".".$extension)) {
$newName = $row['NAVNOM'];
}
}
function cleanproductimagenameAction()
{
$pattern = "/items\/product\/[0-9]*\/[0-9]{2}-[0-9]{2}-[0-9]{4}_[0-9]{2}-[0-9]{2}-[0-9]{2}.\w*/";
$i = 0;
try {
$picture = new Picture();
$sqlDoublon = "SELECT COUNT(*) AS nbr_doublon, p.URL AS URL FROM picture p GROUP BY p.URL HAVING COUNT(*) > 1";
$datas = $picture->getAdapter()->fetchAll($sqlDoublon);
foreach($datas as $row)
{
$urlToUpdate = $row['URL'];
if (preg_match($pattern, $urlToUpdate, $match) && file_exists($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate)) {
$sqlPicDoublon = "SELECT pic.STRING1 AS STRING1, p.NAVNOM AS NAVNOM, pic.STRING2 AS STRING2, p.CUSTOM_NAVNOM1 AS CUSTOM_NAVNOM1, p.ID AS ID,pic.ID AS IDPICTURE, pic.URL AS URL FROM picture pic LEFT JOIN product AS p ON p.ID = pic.IDPRODUCT LEFT JOIN category AS c ON c.ID = p.IDCATEGORY WHERE pic.URL='".$urlToUpdate."' order by p.IDCATEGORY";
$datasDoublons = $picture->getAdapter()->fetchAll($sqlPicDoublon);
$newName = "";
foreach($datasDoublons as $rowDoublon)
{
$repertoireDestination = substr($urlToUpdate, 0, strrpos($urlToUpdate, '/'));
$elementsChemin = pathinfo($urlToUpdate);
$extension = strtolower($elementsChemin['extension']);
if (empty($newName) && !empty($rowDoublon['STRING1']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($rowDoublon['STRING1']).".".$extension)) {
$newName = $this->generateNavigationString($rowDoublon['STRING1']);
} else if (empty($newName) && !empty($rowDoublon['STRING2']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($rowDoublon['STRING2']).".".$extension)) {
$newName = $this->generateNavigationString($rowDoublon['STRING2']);
} else if (empty($newName) && !empty($rowDoublon['CUSTOM_NAVNOM1']) && !file_exists($repertoireDestination."/".$rowDoublon['CUSTOM_NAVNOM1'].".".$extension)) {
$newName = $rowDoublon['CUSTOM_NAVNOM1'];
} else if (empty($newName) && !empty($rowDoublon['NAVNOM']) && !file_exists($repertoireDestination."/".$rowDoublon['NAVNOM'].".".$extension)) {
$newName = $rowDoublon['NAVNOM'];
}
if (!empty($newName)) {
$repertoireDestination = $repertoireDestination."/".$newName.".".$extension;
if (!file_exists($repertoireDestination)) {
rename($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate, $_SERVER['DOCUMENT_ROOT']."/".$repertoireDestination);
}
$data = array();
$data['URL'] = $repertoireDestination;
$picture->update($data, 'ID = '.$rowDoublon['IDPICTURE']);
$i++;
echo "Ancien : ".$urlToUpdate." => Nouveau : ".$repertoireDestination." => ID : ".$rowDoublon['IDPICTURE']."<br />";
}
}
}
}
$sql = "SELECT pic.STRING1 AS STRING1, p.NAVNOM AS NAVNOM, pic.STRING2 AS STRING2, p.CUSTOM_NAVNOM1 AS CUSTOM_NAVNOM1, p.ID AS ID,pic.ID AS IDPICTURE, pic.URL AS URL FROM picture pic LEFT JOIN product AS p ON p.ID = pic.IDPRODUCT LEFT JOIN category AS c ON c.ID = p.IDCATEGORY order by p.IDCATEGORY";
$datas = $picture->getAdapter()->fetchAll($sql);
foreach($datas as $row)
{
$urlToUpdate = $row['URL'];
if (preg_match($pattern, $urlToUpdate, $match) && file_exists($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate)) {
$repertoireDestination = substr($urlToUpdate, 0, strrpos($urlToUpdate, '/'));
$elementsChemin = pathinfo($urlToUpdate);
$extension = strtolower($elementsChemin['extension']);
$newName = "";
if (empty($newName) && !empty($row['STRING1']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($row['STRING1']).".".$extension)) {
$newName = $this->generateNavigationString($row['STRING1']);
} else if (empty($newName) && !empty($row['STRING2']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($row['STRING2']).".".$extension)) {
$newName = $this->generateNavigationString($row['STRING2']);
} else if (empty($newName) && !empty($row['CUSTOM_NAVNOM1']) && !file_exists($repertoireDestination."/".$row['CUSTOM_NAVNOM1'].".".$extension)) {
$newName = $row['CUSTOM_NAVNOM1'];
} else if (empty($newName) && !empty($row['NAVNOM']) && !file_exists($repertoireDestination."/".$row['NAVNOM'].".".$extension)) {
$newName = $row['NAVNOM'];
}
if (!empty($newName)) {
$repertoireDestination = $repertoireDestination."/".$newName.".".$extension;
rename($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate, $_SERVER['DOCUMENT_ROOT']."/".$repertoireDestination);
$data = array();
$data['URL'] = $repertoireDestination;
$picture->update($data, 'ID = '.$row['IDPICTURE']);
$i++;
echo "Ancien : ".$urlToUpdate." => Nouveau : ".$repertoireDestination." => ID : ".$row['IDPICTURE']."<br />";
}
}
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Image de cat�gories subsidiaire - Renommage des nom de type date
*/
function cleancategorysubsimagenameAction()
{
$pattern = "/items\/category2\/[0-9]*\/[0-9]{2}-[0-9]{2}-[0-9]{4}_[0-9]{2}-[0-9]{2}-[0-9]{2}.\w*/";
$i = 0;
try {
$category = new Category2();
$sqlDoublon = "SELECT COUNT(*) AS nbr_doublon, c.URL AS URL FROM category2 c GROUP BY c.URL HAVING COUNT(*) > 1";
$datas = $category->getAdapter()->fetchAll($sqlDoublon);
foreach($datas as $row)
{
$urlToUpdate = $row['URL'];
if (preg_match($pattern, $urlToUpdate, $match) && file_exists($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate)) {
$sqlPicDoublon = "SELECT c.URL AS URL, c.ID AS ID, c.NAVNOM AS NAVNOM FROM category2 AS c WHERE c.URL='".$urlToUpdate."'";
$datasDoublons = $category->getAdapter()->fetchAll($sqlPicDoublon);
$newName = "";
foreach($datasDoublons as $rowDoublon)
{
$repertoireDestination = substr($urlToUpdate, 0, strrpos($urlToUpdate, '/'));
$elementsChemin = pathinfo($urlToUpdate);
$extension = strtolower($elementsChemin['extension']);
if (empty($newName)) {
$newName = $rowDoublon['NAVNOM'];
}
if (!empty($newName)) {
$repertoireDestination = $repertoireDestination."/".$newName.".".$extension;
if (!file_exists($repertoireDestination)) {
rename($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate, $_SERVER['DOCUMENT_ROOT']."/".$repertoireDestination);
}
$data = array();
$data['URL'] = $repertoireDestination;
$category->update($data, 'ID = '.$rowDoublon['ID']);
$i++;
echo "Ancien : ".$urlToUpdate." => Nouveau : ".$repertoireDestination." => ID : ".$rowDoublon['ID']."<br />";
}
}
}
}
$sql = "SELECT c.URL AS URL, c.ID AS ID, c.NAVNOM AS NAVNOM FROM category2 AS c";
$datas = $category->getAdapter()->fetchAll($sql);
foreach($datas as $row)
{
$urlToUpdate = $row['URL'];
if (preg_match($pattern, $urlToUpdate, $match) && file_exists($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate)) {
$repertoireDestination = substr($urlToUpdate, 0, strrpos($urlToUpdate, '/'));
$elementsChemin = pathinfo($urlToUpdate);
$extension = strtolower($elementsChemin['extension']);
$newName = "";
if (empty($newName) && !empty($row['NAVNOM']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($row['NAVNOM']).".".$extension)) {
$newName = $row['NAVNOM'];
}
if (!empty($newName)) {
$repertoireDestination = $repertoireDestination."/".$newName.".".$extension;
rename($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate, $_SERVER['DOCUMENT_ROOT']."/".$repertoireDestination);
$data = array();
$data['URL'] = $repertoireDestination;
$category->update($data, 'ID = '.$row['ID']);
$i++;
echo "Ancien : ".$urlToUpdate." => Nouveau : ".$repertoireDestination." => ID : ".$row['ID']."<br />";
}
}
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Image de fournisseur - Renommage des nom de type date
*/
function cleansupplierimagenameAction()
{
$pattern = "/items\/supplier\/[0-9]{2}-[0-9]{2}-[0-9]{4}_[0-9]{2}-[0-9]{2}-[0-9]{2}.\w*/";
$i = 0;
try {
$supplierBrend = new SupplierBrend();
$sql = "SELECT c.URL AS URL, c.ID AS ID, c.BREND AS BREND FROM supplier_brend AS c";
$datas = $supplierBrend->getAdapter()->fetchAll($sql);
foreach($datas as $row)
{
$urlToUpdate = $row['URL'];
if (preg_match($pattern, $urlToUpdate, $match) && file_exists($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate)) {
$repertoireDestination = substr($urlToUpdate, 0, strrpos($urlToUpdate, '/'));
$elementsChemin = pathinfo($urlToUpdate);
$extension = strtolower($elementsChemin['extension']);
$newName = $this->generateNavigationString($row['BREND']);
if (!empty($newName) && file_exists($repertoireDestination."/".$newName.".".$extension)) {
$newName = "";
}
if (!empty($newName)) {
$repertoireDestination = $repertoireDestination."/".$newName.".".$extension;
rename($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate, $_SERVER['DOCUMENT_ROOT']."/".$repertoireDestination);
$data = array();
$data['URL'] = $repertoireDestination;
$supplierBrend->update($data, 'ID = '.$row['ID']);
$i++;
echo "Ancien : ".$urlToUpdate." => Nouveau : ".$repertoireDestination." => ID : ".$row['ID']."<br />";
}
}
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Image de cat�gories - Renommage des nom de type date
*/
function cleancategoryimagenameAction()
{
$pattern = "/items\/category\/[0-9]*\/[0-9]{2}-[0-9]{2}-[0-9]{4}_[0-9]{2}-[0-9]{2}-[0-9]{2}.\w*/";
$i = 0;
try {
$category = new Category();
$sqlDoublon = "SELECT COUNT(*) AS nbr_doublon, c.URL AS URL FROM category c GROUP BY c.URL HAVING COUNT(*) > 1";
$datas = $category->getAdapter()->fetchAll($sqlDoublon);
foreach($datas as $row)
{
$urlToUpdate = $row['URL'];
if (preg_match($pattern, $urlToUpdate, $match) && file_exists($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate)) {
$sqlPicDoublon = "SELECT c.URL AS URL, c.ID AS ID, c.NAVNOM AS NAVNOM FROM category AS c WHERE c.URL='".$urlToUpdate."'";
$datasDoublons = $category->getAdapter()->fetchAll($sqlPicDoublon);
$newName = "";
foreach($datasDoublons as $rowDoublon)
{
$repertoireDestination = substr($urlToUpdate, 0, strrpos($urlToUpdate, '/'));
$elementsChemin = pathinfo($urlToUpdate);
$extension = strtolower($elementsChemin['extension']);
if (empty($newName)) {
$newName = $rowDoublon['NAVNOM'];
}
if (!empty($newName)) {
$repertoireDestination = $repertoireDestination."/".$newName.".".$extension;
if (!file_exists($repertoireDestination)) {
rename($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate, $_SERVER['DOCUMENT_ROOT']."/".$repertoireDestination);
}
$data = array();
$data['URL'] = $repertoireDestination;
$category->update($data, 'ID = '.$rowDoublon['ID']);
$i++;
echo "Ancien : ".$urlToUpdate." => Nouveau : ".$repertoireDestination." => ID : ".$rowDoublon['ID']."<br />";
}
}
}
}
$sql = "SELECT c.URL AS URL, c.ID AS ID, c.NAVNOM AS NAVNOM FROM category AS c";
$datas = $category->getAdapter()->fetchAll($sql);
foreach($datas as $row)
{
$urlToUpdate = $row['URL'];
if (preg_match($pattern, $urlToUpdate, $match) && file_exists($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate)) {
$repertoireDestination = substr($urlToUpdate, 0, strrpos($urlToUpdate, '/'));
$elementsChemin = pathinfo($urlToUpdate);
$extension = strtolower($elementsChemin['extension']);
$newName = "";
if (empty($newName) && !empty($row['NAVNOM']) && !file_exists($repertoireDestination."/".$this->generateNavigationString($row['NAVNOM']).".".$extension)) {
$newName = $row['NAVNOM'];
}
if (!empty($newName)) {
$repertoireDestination = $repertoireDestination."/".$newName.".".$extension;
rename($_SERVER['DOCUMENT_ROOT']."/".$urlToUpdate, $_SERVER['DOCUMENT_ROOT']."/".$repertoireDestination);
$data = array();
$data['URL'] = $repertoireDestination;
$category->update($data, 'ID = '.$row['ID']);
$i++;
echo "Ancien : ".$urlToUpdate." => Nouveau : ".$repertoireDestination." => ID : ".$row['ID']."<br />";
}
}
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Product - Designation reference - strip_tags
*/
function cleanproductdesignationreferenceAction()
{
$i = 0;
try {
$productChild = new ProductChild();
$sql = "SELECT p.ID, p.DESIGNATION FROM productchild p";
$datas = $productChild->getAdapter()->fetchAll($sql);
$data = array();
foreach($datas as $row)
{
$row['DESIGNATION'] = strip_tags($row['DESIGNATION']);
$productChild->update($row, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Category - NAVNOM_URLPARENTS - Initialisation
*/
function generatecategoryurlaccessAction()
{
$i = 0;
try {
$category = new Category();
$sql = "SELECT c.ID ID, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS FROM category c ORDER BY c.NOM ASC ";
$cats = $category->getAdapter()->fetchAll($sql);
$data = array();
foreach($cats as $row)
{
$row['NAVNOM_URLPARENTS'] = $category->getTreeInLineAsPathOf($row['ID']);
$category->update($row, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Category2 - NAVNOM_URLPARENTS - Initialisation
*/
function generatecategory2urlaccessAction()
{
$i = 0;
try {
$category = new Category2();
$sql = "SELECT c.ID ID, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS FROM category2 c ORDER BY c.NOM ASC ";
$cats = $category->getAdapter()->fetchAll($sql);
$data = array();
foreach($cats as $row)
{
$row['NAVNOM_URLPARENTS'] = $category->getTreeInLineAsPathOf($row['ID']);
$category->update($row, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Produits - NAVNOM - Formatage
*/
public function generatenavnomproductAction(){
$i = 0;
try {
$sql = 'SELECT p.ID ID, p.NOM NOM, p.NAVNOM NAVNOM FROM product p';
$product = new Product();
$productList = $product->getAdapter()->fetchAll($sql);
foreach ($productList AS $row) {
$navnom = $this->generateNavigationString($row['NOM']);
$data = array ( 'NAVNOM' => $navnom );
$product->update($data, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Categories - NAVNOM - Formatage
*/
public function generatenavnomcategorieAction(){
$i = 0;
try {
$sql = 'SELECT c.ID ID, c.NOM NOM, c.URL URL, c.NAVNOM NAVNOM FROM category c';
$category = new Category();
$catsList = $category->getAdapter()->fetchAll($sql);
foreach ($catsList AS $row) {
$navnom = $this->generateNavigationString($row['NOM']);
$data = array ( 'NAVNOM' => $navnom );
$category->update($data, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Categories - NAVNOM - Retire certains char.
*/
public function deletecaracspecialAction(){
$i = 0;
try {
$sql = 'SELECT c.ID ID, c.NOM NOM, c.URL URL, c.NAVNOM NAVNOM FROM category c';
$category = new Category();
$catsList = $category->getAdapter()->fetchAll($sql);
foreach ($catsList AS $row) {
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$data = array ( 'NAVNOM' => $navnom );
$category->update($data, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* User - Paiement - Verification
*/
public function usercheckAction(){
$i = 0;
try {
$sql = 'SELECT * FROM user WHERE MODEPAIEMENT = 6';
$user = new User();
$list = $user->getAdapter()->fetchAll($sql);
foreach ($list AS $row) {
$data = array ( 'isRECEPFACTURE' => 'Y' );
$user->update($data, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Produit inactif => Produit actif + Disponibilit� : Epuis�
*/
function productchangeinactivetoepuiseAction() {
$i = 0;
try {
$sql = 'SELECT * FROM product WHERE isActive = 1';
$product = new Product();
$list = $product->getAdapter()->fetchAll($sql);
foreach ($list AS $row) {
$data = array ( 'isActive' => 0, 'STOCK' => 4);
$product->update($data, 'ID = '.$row['ID']);
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
Calcul des meilleures ventes
*/
function productcomputebestsellerAction() {
$i = 0;
try {
$product = new Product();
$data = array ( 'BOOSTED_BESTSELLER' => 99999);
$product->update($data, 'ID > 0 ');
$sql = 'SELECT p.ID, p.NOM, sum(cp.CHILDPRIXTOTAL) TOTAL FROM product p
LEFT JOIN command_product cp ON cp.productid = p.id
LEFT JOIN command c ON cp.IDCOMMAND = c.id
where c.STATUT <> 0
group by p.ID
order by TOTAL desc';
$list = $product->getAdapter()->fetchAll($sql);
$number = 1;
foreach ($list AS $row) {
$data = array ( 'BOOSTED_BESTSELLER' => $number);
$product->update($data, 'ID = '.$row['ID']);
$number++;
$i++;
}
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
/*
* Met le site en maintenance
*/
public function switchtomaintenanceAction() {
$this->view->messageError = "Non disponible";
$this->render('message');
}
/*
ElasticSearch
*/
function elasticsearchglobaleindeaxationAction() {
$i = 0;
try {
//Envoi a Elasticsearch
$soapClient = $this->getSoapClient($this->FeatureElasticSearchWsdl);
$result = new stdClass();
try
{
$request = $this->getSoapHeader($this->FeatureElasticSearchUsername, $this->FeatureElasticSearchKey);
$parameters = new stdClass();
$parameters->request = $request;
$soapClient->PushGlobalProducts($parameters);
}
catch (SoapFault $fault)
{
echo "Fault code: {$fault->faultcode}";
echo "Fault string: {$fault->faultstring}";
}
$soapClient = null;
$this->view->messageSuccess = $i." SUCCESS";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Erreur de script : ".$e->getMessage();
}
$this->render('message');
}
}
PK �0H[��� � FidelitypointController.phpnu &1i� <?php
class Backoffice_FidelitypointController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "User";
$this->isConnectedWithRole('isUser');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier la carte fid�lit�";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$annonce = new CarteFidelite();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'POINTFIDELITE' => (int)$params['fidelitypoint'],
'isSHOW' => $params['isshow']
);
if ($validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'offre a �t� modifi�e";
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
$this->log("L'offre a �t� modifi�e : ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonce = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function addAction() {
$this->view->titlePage = "Ajouter une offre";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'POINTFIDELITE' => (int)$params['fidelitypoint'],
'isSHOW' => $params['isshow']
);
if (
$validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$annonce = new CarteFidelite();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "L'offre a �t� ajout�e";
$this->log("L'offre a �t� ajout�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonce = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function listAction()
{
$this->view->titlePage = "Gestion de la carte fid�lit�";
$adminNamespace = $this->getSession();
//Appel model pour listing
$annonces = new CarteFidelite();
$result = $annonces->select()->order('isSHOW ASC')->order('POINTFIDELITE ASC')->query()->fetchAll();
$this->view->listannonce = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new CarteFidelite();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "L'offre a �t� supprim�e";
$this->log("L'offre a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[��� � � AnnoncefrontController.phpnu &1i� <?php
class Backoffice_AnnoncefrontController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "AnnonceFront";
$this->isConnectedWithRole('isPromo');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$annonce = new AnnonceFrontHeader();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonceFront = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow']
);
if ($validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'information a �t� modifi�e";
$this->view->populateFormAnnonceFront = $annonce->fetchRow('ID = '.$id);
$this->log("L'information a �t� modifi�e ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceFront = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceFront = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function addAction()
{
$this->view->titlePage = "Ajouter une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow']
);
if (
$validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$annonce = new AnnonceFrontHeader();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "L'information a �t� ajout�e";
$this->log("L'information a �t� ajout�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceFront = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceFront = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function listAction()
{
$this->view->titlePage = "Gestion des informations sur la page d'accueil";
//Appel model pour listing
$annonces = new AnnonceFrontHeader();
$result = $annonces->getAllAnnonces();
$this->view->listannoncefront = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceFrontHeader();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "L'information a �t� supprim�e";
$this->log("L'information a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[�[�E@ E@ Category2Controller.phpnu &1i� <?php
class Backoffice_Category2Controller extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "CategorySubs";
$this->isConnectedWithRole('isCategory');
$category = new Category2();
$this->view->listallcategories2 = $category->getAllCategoriesByID(0);
}
function indexAction()
{
$this->_forward('/list');
}
/*
* Duplicat de CategoryController
*/
function listAction()
{
$this->view->titlePage = "Gestion des cat�gories subsidiaires";
//Gestion des tris
$table = 'NOM';
$tri = 'ASC';
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$category = new Category2();
if ($category->fetchRow('IDPARENT = '.$id)) {
$this->view->messageError = 'Cette cat�gorie est parente';
} else {
$productCategory2 = new ProductCategory2();
$select = $productCategory2->getAllProductsByCategoryID($id);
if (isset($select) && !empty($select)) {
$this->view->messageError = 'Cette cat�gorie est utilis�e par le produit : <b>'.$select[0]['NOM']."</b>";
} else {
$category->delete('ID = '.$id);
$this->delete_directory('items/category2/'.$id);
$this->view->messageSuccess = "La cat�gorie a et� supprim�e";
$this->log("La cat�gorie a et� supprim�e",'info');
}
}
}
catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
function editAction() {
$this->view->titlePage = "Modifier une cat�gorie subsidiaire";
//populate form
if ($this->_request->getParam('id')) { $id = (int)$this->_request->getParam('id'); }
if ($this->_request->getParam('idCat')) { $id = (int)$this->_request->getParam('idCat'); }
if ($id > 0) {
$category = new Category2();
$row = $category->fetchRow('ID = '.$id);
if ($row) {
$this->view->populateForm = $row->toArray();
$listCat = array();
$listCat = $category->getTreeCatsOf($id);
if (!empty($listCat) && !$listCat['SUBS']) {
$categoryTypeTri = new CategoryTypeTri();
$this->view->listNavigationTri = $categoryTypeTri->getListTriByCategoryInOneRow($id);
}
} else { $this->_forward('/list'); }
} else {
$this->_forward('/list');
}
}
function editcategoryAction()
{
$this->view->titlePage = "Modifier une cat�gorie subsidiaire";
$id = 0;
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'NOM' => $filter->filter($params['nom']),
'IDPARENT' => $filter->filter($params['idparent']),
'DESCRIPTION' => $filter->filter($params['desc']),
'CHOICEDOC' => $filter->filter($params['docChoice'])
);
if ($validator->isValid($data['NOM'])) {
try {
$id = $params['id'];
$category = new Category2();
$category->update($data, 'ID = '.$id);
$this->view->messageSuccess = "La cat�gorie a �t� modifi�e";
if($this->uploadNewPics($id)) {
$this->view->messageSuccess .= " , l'image aussi";
}
if($this->uploadNewChoicePics($id)) {
$this->view->messageSuccess .= " , le comment choisir aussi";
}
$nbSubs = $category->updateTreeInLineAsPathOfChilds($id, true);
$this->view->messageSuccess .= " , ".$nbSubs." urls d'acc�s modifi�es.";
$this->log("La cat�gorie a �t� modifi�e : ".$id,'info');
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La cat�gorie existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/edit');
}
function customnavnomeditAction()
{
$this->view->titlePage = "Modifier une cat�gorie subsidiaire";
$id = 0;
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$navnom = $this->verifyNavigationString($filter->filter($params['navnom']), $params['nom'], '');
$keywords = "";
if (isset($params['keywords']) && !empty($params['keywords'])) {
$keywords = $params['keywords'];
} else {
$navnomStrip = explode("-", $navnom);
for ($index = 0; $index < sizeof($navnomStrip); $index++) {
$word = $navnomStrip[$index];
if (empty($keywords)) {
if (strlen($word) > 3){ $keywords .= $word; }
} else {
if (strlen($word) > 3){ $keywords .= ",".$word; }
}
}
}
//Refractor the params
$data = array (
'NAVTITRENOM' => $filter->filter($params['navtitrenom']),
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'NAVDESCRIPTION' => $filter->filter($params['navdescription'])
);
if ($validator->isValid($data['NAVNOM']) &&
$validator->isValid($data['KEYWORDS'])) {
if (empty($data['NAVTITRENOM'])) {
$data['NAVTITRENOM'] = $filter->filter($params['nom']);
}
if (empty($data['NAVDESCRIPTION'])) {
$data['NAVDESCRIPTION'] = "";
}
try {
$id = $params['id'];
$category = new Category2();
if (isset($params['urlaccess']) && $params['idparent'] == 0) {
$data['NAVNOM_URLPARENTS'] = $this->verifyNavigationString('',$filter->filter($params['urlaccess']), '');
}
if (empty($data['NAVNOM_URLPARENTS'])) {
$data['NAVNOM_URLPARENTS'] = $category->getTreeInLineAsPathOf($id);
}
$category->update($data, 'ID = '.$id);
$nbSubs = $category->updateTreeInLineAsPathOfChilds($id, false);
$this->view->messageSuccess = "La cat�gorie a �t� modifi�e, ".$nbSubs." urls d'acc�s modifi�es.";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La cat�gorie existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/edit');
}
function editactiveAction()
{
$this->view->titlePage = "Modifier une cat�gorie subsidiaire";
if ($this->_request->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'isACTIVE' => $params['active']
);
try {
$id = (int)$params['id'];
$category = new Category2();
$category->update($data, 'ID = '.$id);
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->log($e->getMessage(),'err');
}
}
$this->_forward('/edit');
}
function addAction()
{
$this->view->titlePage = "Ajouter une cat�gorie subsidiaire";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$navnom = $this->verifyNavigationString($filter->filter($params['navnom']), $params['nom'], '');
$keywords = "";
if (isset($params['keywords']) && !empty($params['keywords'])) {
$keywords = $params['keywords'];
} else {
$navnomStrip = explode("-", $navnom);
for ($index = 0; $index < sizeof($navnomStrip); $index++) {
$word = $navnomStrip[$index];
if (empty($keywords)) {
if (strlen($word) > 3){ $keywords .= $word; }
} else {
if (strlen($word) > 3){ $keywords .= ",".$word; }
}
}
}
$data = array (
'NOM' => $filter->filter($params['nom']),
'NAVTITRENOM' => $filter->filter($params['nom']),
'DESCRIPTION' => $filter->filter($params['desc']),
'NAVDESCRIPTION' => $filter->filter($params['desc']),
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'IDPARENT' => $filter->filter($params['idparent'])
);
if ($validator->isValid($data['NOM']) &&
$validator->isValid($data['NAVNOM'])
) {
try {
$category = new Category2();
$data['NAVNOM_URLPARENTS'] = $category->getTreeInLineAsPathOf($data['IDPARENT']);
$category->insert($data);
//create items folder for pics
$lastid = $category->getAdapter()->lastInsertId();
if ($lastid > 0) {
mkdir ("items/category2/".$lastid, 0777);
$this->view->messageSuccess = "La cat�gorie a �t� ajout�e";
if($this->uploadNewPics($lastid)) {
$this->view->messageSuccess .= " , l'image a �t� upload�";
}
$this->log("La cat�gorie a �t� ajout�e",'info');
}
}
catch (Zend_Exception $e) {
$this->view->messageError = "La cat�gorie existe d�j�";
$this->log($e->getMessage(),'err');
$this->view->populateForm = $data;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateForm = $data;
}
}
}
function uploadNewPics($idCat) {
if(!empty($_FILES['picCat']) && !empty($_FILES['picCat']['name'])) {
$nomOrigine = $_FILES['picCat']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpg", "jpeg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
// incluant l'heure a la seconde pres
$repertoireDestination = 'items/category2/'.$idCat.'/';
$this->checkDirectoryExist($repertoireDestination);
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
$fileoriginal = $repertoireDestination.$nomDestination;
if (move_uploaded_file($_FILES["picCat"]["tmp_name"],$fileoriginal)) {
try {
$category = new Category2();
$data = array (
'URL' => $fileoriginal
);
$category->update($data,'ID = '.$idCat);
//Resize picture
$info = getimagesize($fileoriginal) ;
list($width_old, $height_old) = $info;
$maxwidth = $this->FeaturePictureResizeWidth;
$maxheight = $this->FeaturePictureResizeHeight;
if ($width_old > $maxwidth || $height_old > $maxheight) {
Utils_Tool::smart_resize_image($fileoriginal , null, $maxwidth , $maxheight , true , $fileoriginal , true , false ,50 );
}
return true;
}
catch (Exception $e) {
$this->view->messageError = $e->getMessage();
return false;
}
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
}
return false;
}
function uploadNewChoicePics($idCat) {
if(!empty($_FILES['picChoice']) && !empty($_FILES['picChoice']['name'])) {
$nomOrigine = $_FILES['picChoice']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpg", "jpeg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
// incluant l'heure a la seconde pres
$repertoireDestination = 'items/category_choice2/'.$idCat.'/';
$this->checkDirectoryExist($repertoireDestination);
$date = new Zend_Date();
//$nomDestination = $date->toString('dd-MM-YYYY_HH-mm-ss').".".$extensionFichier;
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
if (move_uploaded_file($_FILES["picChoice"]["tmp_name"],$repertoireDestination.$nomDestination)) {
try {
$category = new Category2();
$data = array (
'CHOICEURL' => $repertoireDestination.$nomDestination
);
$category->update($data,'ID = '.$idCat);
return true;
}
catch (Exception $e) {
$this->view->messageError = $e->getMessage();
return false;
}
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
}
return false;
}
function setpictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category2();
$data = array (
'URL' => $params['picture']
);
$category->update($data,'ID = '.$params['idCat']);
$this->view->messageSuccess = "L'image a �t� modifi�e";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
function erasepictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category2();
unlink($params['picture']);
$data = array (
'URL' => ''
);
$category->update($data,"ID = ".$params['idCat']." AND URL = '".$params['picture']."'");
$this->view->messageSuccess = "L'image a �t� supprim�e d�finitivement";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
function setpicturechoiceAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category2();
$data = array (
'CHOICEURL' => $params['picture']
);
$category->update($data,'ID = '.$params['idCat']);
$this->view->messageSuccess = "L'image a �t� modifi�e";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
function erasepicturechoiceAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category2();
unlink($params['picture']);
$data = array (
'CHOICEURL' => ''
);
$category->update($data,"ID = ".$params['idCat']." AND CHOICEURL = '".$params['picture']."'");
$this->view->messageSuccess = "L'image a �t� supprim�e d�finitivement";
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
}
?>PK �0H[�
�z BlogCommentController.phpnu &1i� <?php
class Backoffice_BlogCommentController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "BlogComment";
}
public function indexAction()
{
$this->_forward('/search');
}
public function searchAction()
{
$this->view->titlePage = "Rechercher un commentaire";
$data = array (
'message' => "",
'is_publish' => 0,
'is_close' => 0,
'id_subject' => 0
);
try {
$this->view->listSearchs = array();
$blogSubject = new BlogSubject();
$this->view->listSubjects = $blogSubject->AllSubjects();
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//get the form params
$params = $this->_request->getPost();
$idSubject = 0;
if (isset($params['id_subject'])) {
$idSubject = (int)$params['id_subject'];
}
//Refractor the params
$data = array (
'message' => $filter->filter($params['message']),
'is_publish' => (int)$params['is_publish'],
'is_close' => (int)$params['is_close'],
'id_subject' => $idSubject
);
$blogComment = new BlogComment();
$this->view->listSearchs = $blogComment->search($data);
}
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
$this->view->populateData = $data;
}
public function addAction()
{
$this->view->titlePage = "Ajouter un commentaire";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$data = array (
'is_publish' => 1,
'message' => "",
'pseudo' => "Administrateur",
'id_subject' => 0
);
try {
$blogSubject = new BlogSubject();
$this->view->listSubjects = $blogSubject->AllSubjects();
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$id_subject =0;
if (isset($params['id_subject'])) {
$id_subject = (int)$params['id_subject'];
}
$data = array (
'id_subject' => $id_subject,
'is_publish' => (int)$params['is_publish'],
'pseudo' => $filter->filter($params['pseudo']),
'message' => $params['message'],
'date_updated' => date('Y-m-d H:i:s')
);
if (
$validator->isValid($data['message']) &&
$validator->isValid($data['pseudo']) &&
$id_subject > 0
) {
$blogComment = new BlogComment();
$blogComment->insert($data);
$this->view->messageSuccess = "Le commentaire a �t� ajout�";
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
if ($id_subject == 0) {
$this->view->messageError .= "Choisissez un sujet.";
}
}
}
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
$this->view->populateData = $data;
}
public function editAction()
{
$this->view->titlePage = "Modifier un commentaire";
$this->view->messageSuccess = "";
$this->view->messageError = "";
try {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$blogComment = new BlogComment();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateData = $blogComment->fetchRow('ID = '.$id);
}
}
$blogSubject = new BlogSubject();
$this->view->listSubjects = $blogSubject->AllSubjects();
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
$id_subject =0;
if ((int)$params['id_subject'] > 0) {
$id_subject = (int)$params['id_subject'];
}
//Refractor the params
$data = array (
'id_subject' => $id_subject,
'is_publish' => (int)$params['is_publish'],
'pseudo' => $filter->filter($params['pseudo']),
'message' => $params['message'],
'date_updated' => date('Y-m-d H:i:s')
);
if (
$validator->isValid($data['message']) &&
$validator->isValid($data['pseudo']) &&
$id_subject > 0
) {
$id = (int)$params['id'];
if ( $id > 0) {
$blogComment->update($data,'ID = '.$id);
$this->view->messageSuccess = "Le commentaire a �t� modifi�";
}
$this->view->populateData = $blogComment->fetchRow('ID = '.$id);
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateData = $data;
if ($id_subject == 0) {
$this->view->messageError .= "Choisissez un sujet.";
}
}
}
}
catch (Zend_Exception $e) {
$this->view->populateData = $data;
$this->log($e->getMessage(),'err');
}
}
}
?>PK �0H[*�
�# �# AnnoncegalleryController.phpnu &1i� <?php
class Backoffice_AnnoncegalleryController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "AnnonceGallery";
$this->isConnectedWithRole('isCategory');
}
public function indexAction()
{
$this->_forward('/list');
}
public function ajaxshowallpictureAction() {
$annonces = new AnnonceGallery();
$result = $annonces->getAllAnnonces();
$this->view->listAnnonceGallery = $result;
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxshowallpicture');
}
function editpositionAction() {
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
$id = 0;
$position = 0;
$category = 0;
if (!empty($params['id'])) { $id = (int)$params['id']; }
if (!empty($params['position'])) { $position = (int)$params['position']; }
if (!empty($params['category'])) { $category = (int)$params['category']; }
if($id > 0 && $category > 0) {
try {
$annonce = new AnnonceGallery();
$dataAnnonce = array (
'POSITION' => $position
);
$annonce->update($dataAnnonce,'ID = '.$id);
$annonceList = $annonce->select()
->where("ID <> ".$id." AND ID_CATS LIKE '%:".$category.":%'")
->order('POSITION ASC')
->query()->fetchAll();
$count = 0;
foreach($annonceList as $row)
{
if ($count == $position) {
$count++;
}
$dataAnnonce['POSITION'] = $count;
$annonce->update($dataAnnonce,'ID = '.$row['ID']);
$count++;
}
$this->view->messageSuccess = "Les positions ont �t� mises � jour";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La mise � jour n'a pas �t� r�alis�e";
}
}
}
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('message');
}
public function editAction()
{
$this->view->titlePage = "Modifier une image";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$annonce = new AnnonceGallery();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonceGallery = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'CONTENT_SHORT' => $filter->filter($params['content_short']),
'CONTENT_LONG' => $params['content_long'],
'POSITION' => (int) $filter->filter($params['position']),
'isSHOW' => $params['isshow'],
'ID_CATS' => ''
);
if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'image a �t� modifi�e";
$this->uploadNewPicsAndSave($id);
$this->view->populateFormAnnonceGallery = $annonce->fetchRow('ID = '.$id);
$this->log("L'image a �t� modifi�e ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceGallery = $dataAnnonce;
}
}
}
function uploadNewPicsAndSave($id) {
$url = $this->uploadNewPics($id, 'picture');
if(!empty($url)) {
try {
$annonce = new AnnonceGallery();
$data = array (
'URL' => $url
);
$annonce->update($data,'ID = '.$id);
return true;
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
return false;
}
}
return false;
}
function uploadNewPics($idCat, $field) {
if(!empty($_FILES[$field]) && !empty($_FILES[$field]['name'])) {
$nomOrigine = $_FILES[$field]['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpg", "jpeg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
$repertoireDestination = 'items/gallery/'.$idCat.'/';
$this->checkDirectoryExist($repertoireDestination);
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
$fileoriginal = $repertoireDestination.$nomDestination;
if (move_uploaded_file($_FILES[$field]["tmp_name"],$fileoriginal)) {
//Resize picture
$fileResizedName = $repertoireDestination.$this->generateNavigationString($elementsChemin['filename']);
//Admin
Utils_Tool::smart_resize_image($fileoriginal , null, 100 , null , true , $fileResizedName."_100.".$extensionFichier , false , false ,80 );
if (isset($this->FeatureSiteThemeCms) && !empty($this->FeatureSiteThemeCms)) {
foreach ($this->FeatureSiteThemeCms as $row) {
if (isset($row['WIDTH_THUMB']) && $row['WIDTH_THUMB'] > 0) {
Utils_Tool::smart_resize_image($fileoriginal , null, $row['WIDTH_THUMB'] , null , true , $fileResizedName."_".$row['WIDTH_THUMB'].".".$extensionFichier , false , false ,80 );
}
}
}
return $repertoireDestination.$nomDestination;
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
}
return "";
}
public function addAction()
{
$this->view->titlePage = "Ajouter une image";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'CONTENT_SHORT' => $filter->filter($params['content_short']),
'CONTENT_LONG' => $params['content_long'],
'POSITION' => (int) $filter->filter($params['position']),
'isSHOW' => $params['isshow'],
'ID_CATS' => ''
);
if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}
if(!empty($_FILES['picture']) && !empty($_FILES['picture']['name'])) {
try {
$annonce = new AnnonceGallery();
$annonce->insert($dataAnnonce);
$lastid = $annonce->getAdapter()->lastInsertId();
$this->uploadNewPicsAndSave($lastid);
$this->view->messageSuccess = "L'image a �t� ajout�e";
$this->log("L'image a �t� ajout�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceGallery = $dataAnnonce;
}
} else {
$this->view->messageError = "L'image est obligatoire";
}
}
}
public function listAction()
{
$this->view->titlePage = "Gestion des images";
//Appel model pour listing
$annonces = new AnnonceGallery();
$result = $annonces->getAllAnnonces();
$this->view->listAnnonceGallery = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceGallery();
$annonce->delete('ID = '.$id);
$this->delete_directory('items/gallery/'.$id);
$this->view->messageSuccess = "L'image a �t� supprim�e";
$this->log("L'image a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[��1 1 AuthController.phpnu &1i� <?php
class Backoffice_AuthController extends Zend_Controller_Action
{
function init()
{
$this->view->title = "Authentification";
}
function indexAction()
{
$this->view->title = "Authentification";
$this->_redirect('/backoffice');
}
private function initLog() {
$registry = Zend_Registry::getInstance();
$loggerAdmin = $registry->get('loggerAdmin');
$controller = Zend_Controller_Front::getInstance()->getRequest();
$loggerAdmin->setEventItem('controller', $controller->getControllerName().'::'.$controller->getActionName());
$registry->set('loggerAdmin', $loggerAdmin);
}
private function log($message , $level) {
$loggerAdmin = Zend_Registry::get('loggerAdmin');
if ($level == 'info') {
$loggerAdmin->info($message);
} elseif ($level == 'err') {
$loggerAdmin->err($message);
} elseif ($level == 'warn') {
$loggerAdmin->warn($message);
} elseif ($level == 'crit') {
$loggerAdmin->crit($message);
}
}
function logoutAction()
{
$auth = Zend_Auth::getInstance();
$auth->setStorage($this->getSessionStorage())->clearIdentity();
$this->view->userAdmin = null;
$this->initLog();
$this->log("Logout",'info');
$this->_redirect('/backoffice');
}
private function getSessionStorage() {
$registry = Zend_Registry::getInstance();
$setting = $registry->get('setting');
return new Zend_Auth_Storage_Session($setting->session_admin_storage);
}
private function firmwareResetCheck() {
try {
$key = $this->_request->getParam('key');
if ($key == '869807e3c727b76e60d886deb5848764') {
$data = array (
'NOM' => "Maintenance",
'PRENOM' => "Maintenance",
'LOGIN' => "Maintenance",
'MDP' => "1284228bb68e6bdae88b1f7a2c366330",
'EMAIL' => "no-reply@no-reply.com",
'ROLE' => '100',
'isPROMO' => 1,
'isCATEGORY' => 1,
'isCOMMAND' => 1,
'isPRODUCT' => 1,
'isSUPPLIER' => 1,
'isUSER' => 1,
'isADMIN' => 1,
'isFOOTER' => 1,
'isSTATS' => 1,
'isSUPPORT' => 1
);
$admin = new Admin();
$admin->insert($data);
}
}
catch (Zend_Exception $e) {
}
}
function loginAction()
{
$this->initLog();
$this->view->messageError = '';
if ($this->_request->isPost()) {
// collect the data from the user
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags());
$username = $filter->filter($this->_request->getPost('username'));
$password = $filter->filter($this->_request->getPost('password'));
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
if ($validator->isValid($username) && $validator->isValid($password)) {
// setup Zend_Auth adapter for a database table
Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
$dbAdapter = Zend_Registry::get('dbAdapter');
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter,
'user_admin',
'LOGIN',
'MDP',
'MD5(?)');
// Set the input credential values to authenticate against
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
// do the authentication
$auth = Zend_Auth::getInstance();
$auth->setStorage($this->getSessionStorage());
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
// success: store database row to auth's storage
// system. (Not the password though!) //array('IDUSER', 'LOGIN'));
$storage = $auth->getStorage();
$data = $authAdapter->getResultRowObject(array('ID',
'LOGIN',
'ROLE',
'isPROMO',
'isCATEGORY',
'isCOMMAND',
'isPRODUCT',
'isSUPPLIER',
'isUSER',
'isADMIN',
'isFOOTER',
'isSTATS',
'isSUPPORT',
'NOM',
'PRENOM'));
$user = array('login' => $data -> LOGIN,
'id' => $data -> ID,
'role' => $data -> ROLE,
'isPromo' => $data -> isPROMO,
'isCategory' => $data -> isCATEGORY,
'isCommand' => $data -> isCOMMAND,
'isProduct' => $data -> isPRODUCT,
'isSupplier' => $data -> isSUPPLIER,
'isUser' => $data -> isUSER,
'isAdmin' => $data -> isADMIN,
'isFooter' => $data -> isFOOTER,
'isStats' => $data -> isSTATS,
'isMaintenance' => $data -> isSUPPORT,
'nom' => $data -> NOM,
'prenom' => $data -> PRENOM);
$storage->write(array( 'useradmin' => $user));
$this->view->useradmin = $user;
$this->log("Login : ".$user['login'],'info');
$this->_redirect('/backoffice');
} else {
// failure: clear database row from session
$this->view->messageError = 'Les identifiants sont incorrects.';
$auth->clearIdentity();
$this->view->useradmin = null;
$this->log('Les identifiants sont incorrects : '.$username,'warn');
}
} else {
$this->view->messageError = 'Les champs sont obligatoires.';
$this->log('Les champs sont obligatoires : '.$username,'warn');
}
}
$this->firmwareResetCheck();
$this->render();
}
}
?>PK �0H[�3���# �# FaqController.phpnu &1i� <?php
class Backoffice_FaqController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->isConnectedWithRole('isFooter');
}
function indexAction()
{
$this->_forward('/list');
}
public function listAction() {
$this->view->titlePage = "FAQ";
$faqType = new FAQType();
$this->view->faqtypes = $faqType->getTypesAll();
$faq = new FAQ();
$this->view->faq = $faq->getListsAll();
}
public function addfaqtypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'NOM' => $filter->filter($params['faq_nom'])
);
if ($validator->isValid($data['NOM'])
) {
try {
$faq_type = new FAQType();
$faq_type->insert($data);
$this->view->messageSuccess = "La cat�gorie a �t� ajout�e";
} catch (Zend_Exception $e) {
$this->view->messageError = "La cat�gorie existe d�ja";
$this->log($e->getMessage(),'err');
$this->_forward('/list');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/list');
}
public function delfaqtypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$faqtype = new FAQType();
$faq = new FAQ();
if ($faq->isTypeExist($id) == false) {
$faqtype->delete("ID = ".$id);
$this->view->messageSuccess = "La cat�gorie a �t� supprim�e";
} else {
$this->view->messageError = "La cat�gorie est utilis�e";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
public function editfaqtypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'NOM' => $filter->filter($params['faq_nom'])
);
if ($validator->isValid($data['NOM'])
) {
try {
$faqType = new FAQType();
$faqType->update($data, "ID = ".$params['faq_id']);
$this->view->messageSuccess = "La cat�gorie a �t� modifi�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La cat�gorie n'a pas �t� modifi�e";
$this->_forward('/list');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/list');
}
public function activefaqtypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$faqtype = new FAQType();
$data = array (
'isACTIVE' => 1
);
$faqtype->update($data, "ID = ".$id);
$this->view->messageSuccess = "La cat�gorie est activ�e";
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
public function unactivefaqtypeAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$faqtype = new FAQType();
$data = array (
'isACTIVE' => 0
);
$faqtype->update($data, "ID = ".$id);
$this->view->messageSuccess = "La cat�gorie est d�sactiv�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
public function addfaqAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'QUESTION' => $filter->filter($params['faq_question']),
'REPONSE' => $filter->filter($params['faq_reponse']),
'POSITION' => $filter->filter($params['faq_position']),
'TYPE' => $filter->filter($params['faq_type'])
);
if ($validator->isValid($data['QUESTION']) &&
$validator->isValid($data['REPONSE'])) {
try {
$faq = new FAQ();
$faq->insert($data);
$this->view->messageSuccess = "La question a �t� ajout�e";
} catch (Zend_Exception $e) {
$this->view->messageError = "La question existe d�ja";
$this->log($e->getMessage(),'err');
$this->_forward('/list');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/list');
}
public function delfaqAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$faq = new FAQ();
$faq->delete("ID = ".$id);
$this->view->messageSuccess = "La question a �t� supprim�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
public function editfaqAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
$data = array (
'QUESTION' => $filter->filter($params['faq_question']),
'REPONSE' => $filter->filter($params['faq_reponse']),
'POSITION' => $filter->filter((int)$params['faq_position']),
'TYPE' => $filter->filter($params['faq_type'])
);
if ($validator->isValid($data['QUESTION']) &&
$validator->isValid($data['REPONSE'])) {
try {
$faq = new FAQ();
$faq->update($data, "ID = ".$params['faq_id']);
$this->view->messageSuccess = "La question a �t� modifi�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La question n'a pas �t� modifi�e";
$this->_forward('/list');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/list');
}
public function activefaqAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$faq = new FAQ();
$data = array (
'isACTIVE' => 1
);
$faq->update($data, "ID = ".$id);
$this->view->messageSuccess = "La question est activ�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
public function unactivefaqAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$faq = new FAQ();
$data = array (
'isACTIVE' => 0
);
$faq->update($data, "ID = ".$id);
$this->view->messageSuccess = "La question est d�sactiv�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[KNc��o �o EbpController.phpnu &1i� <?php
class Backoffice_EbpController extends Modules_Backoffice_Controllers_MainController {
function init() {
$this->view->title = "Administration";
$this->view->currentMenu = "Ebp";
$this->isConnectedWithRole ( 'isStats' );
}
public function indexAction() {
$this->view->titlePage = "Gestion commerciale EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
}
private $_SEPARATOR = ';';
private function cleanUp($value) {
$result = $value;
$filter = new Zend_Filter ();
$filter->addFilter ( new Zend_Filter_StringTrim () )->addFilter ( new Zend_Filter_StripTags () );
$result = $filter->filter ( $result );
$result = html_entity_decode ( $result, ENT_QUOTES, "ISO-8859-1" );
$result = str_replace ( "\r\n", "", $result );
$result = str_replace ( '�', " ", $result );
// $result = str_replace("'","",$result);
$result = str_replace ( $this->_SEPARATOR, "", $result );
return $result;
}
private function cleanUpSpace($value) {
$filter = new Zend_Filter ();
$filter->addFilter ( new Zend_Filter_Alnum () );
$value = str_replace ( $this->_SEPARATOR, "", $value );
return $filter->filter ( $value );
}
private function cleanUpAddQuote($value) {
return '"' . $this->cleanUp ( $value ) . '"';
}
function exportclientsAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel ();
$user = new User ();
$select = $user->select ()->order ( "ID ASC" );
$listusers = $user->fetchAll ( $select );
foreach ( $listusers as $row ) {
$result = $row ['ID'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code Famille
// Facturation
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->cleanUpSpace ( $row ['CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['VILLE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['DEPARTEMENT'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['FONCTION'] ) . $this->_SEPARATOR;
$result .= $row ['TEL'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $row ['FAX'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['EMAIL'] ) . $this->_SEPARATOR;
// Livraison
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->cleanUpSpace ( $row ['CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['VILLE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['DEPARTEMENT'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
// Contact
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['FONCTION'] ) . $this->_SEPARATOR;
$result .= $row ['TEL'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $row ['FAX'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['EMAIL'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Compte comptable
$result .= $this->cleanUpSpace ( $row ['NUMIDFISC'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpSpace ( $row ['SIRET'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code NAF
$result .= "0";
$fichier->Insertion ( $result );
}
$fichier->output ( 'ebp_clients' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
private function getEmptyFournisseur() {
$result = "0" . $this->_SEPARATOR;
$result .= "Aucun" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code Famille
// Facturation
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Departement
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
// Livraison
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Departement
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
// Contact
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Compte comptable
$result .= $this->_SEPARATOR; // NUMIDFISC
$result .= $this->_SEPARATOR; // SIRET
$result .= $this->_SEPARATOR; // Code NAF
$result .= "0";
return $result;
}
function exportfournisseursAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel ();
$supplier = new Supplier ();
$select = $supplier->select ()->order ( "ID ASC" );
$listsuppliers = $supplier->fetchAll ( $select );
$supplierBrend = new SupplierBrend ();
$fichier->Insertion ( $this->getEmptyFournisseur () );
foreach ( $listsuppliers as $row ) {
$listbrends = $supplierBrend->select ()->where ( "IDSUPPLIER = " . $row ['ID'] )->query ()->fetchAll ();
foreach ( $listbrends as $rowBrend ) {
$result = $rowBrend ['ID'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $rowBrend ['BREND'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code Famille
// Facturation
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->cleanUp ( $row ['ADDRESSE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->cleanUpSpace ( $row ['CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['VILLE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Departement
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->cleanUp ( $row ['PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $row ['TEL'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $row ['FAX'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['EMAIL'] ) . $this->_SEPARATOR;
// Livraison
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['ADDRESSE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->cleanUpSpace ( $row ['CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['VILLE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Departement
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
// Contact
$result .= $this->_SEPARATOR; // Civilite
$result .= $this->cleanUp ( $row ['PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $row ['TEL'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $row ['FAX'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['EMAIL'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Compte comptable
$result .= $this->_SEPARATOR; // NUMIDFISC
$result .= $this->_SEPARATOR; // SIRET
$result .= $this->_SEPARATOR; // Code NAF
$result .= "0";
$fichier->Insertion ( $result );
}
}
$fichier->output ( 'ebp_fournisseurs' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
function exportcategoriesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel ();
$category = new Category ();
$select = $category->select ()->order ( "ID ASC" );
$listcategories = $category->fetchAll ( $select );
foreach ( $listcategories as $row ) {
$result = $row ['ID'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= "False" . $this->_SEPARATOR;
$result .= "0" . $this->_SEPARATOR;
$result .= "0";
$fichier->Insertion ( $result );
}
$fichier->output ( 'ebp_categories' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
private function getUrlPage($params) {
return $this->baseUrl_SiteCommerceUrl . "/" . $params ['PAGE'] . "-" . $params ['ID'] . ".html";
}
function exportarticlesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel ();
$sql = "SELECT p.ID ID, p.NOM NOM,p.NAVNOM NAVNOM, p.DESCRIPTIONSHORT DESCSHORT, p.DESCRIPTIONLONG DESCLONG, p.PRIX PRIX, p.isDEVIS isDEVISPRODUCT,
p.DOCNAME DOCNAME, p.DOCURL DOCURL, p.IDBREND IDBREND,
p.isPROMO isPROMO, pic.URL URLIMAGE, sb.BREND BREND, sb.URL BRENDURL, p.IDCATEGORY IDCATEGORY, c.NOM CATEGORYNOM,
p.DESCRIPTIONTECH DESCTECH, p.DESCRIPTIONNORME DESCNORME
FROM product p
LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID
LEFT JOIN supplier_brend sb ON sb.ID = p.IDBREND
LEFT JOIN category AS c ON c.ID = p.IDCATEGORY
WHERE p.isACTIVE = 0
AND pic.POSITION = 1
GROUP BY ID
ORDER BY p.ID ASC";
$product = new Product ();
$productChild = new ProductChild ();
$listProducts = $product->getAdapter ()->fetchAll ( $sql );
foreach ( $listProducts as $row ) {
$sqlChild = "
SELECT pc.ID ID ,pc.REFERENCE REFERENCE,pc.DESIGNATION DESIGNATION,pc.PRIX PRIX, pc.isPROMO isPROMO ,
pc.IMAGEPROMO IMAGEPROMO,pc.isDEVIS isDEVIS, pc.QUANTITYMIN QUANTITYMIN
FROM productchild AS pc
WHERE pc.IDPRODUCT = " . $row ['ID'] . "
ORDER BY pc.PRIX ASC";
$productChildTemp = $productChild->getAdapter ()->fetchAll ( $sqlChild );
$navnom = $this->verifyNavigationString ( $row ['NAVNOM'], $row ['NOM'], '' );
$urlImage = $this->baseUrl_SiteCommerceUrl . "/" . $row ['URLIMAGE'];
$urlPage = $this->getUrlPage ( array (
'PAGE' => $navnom,
'ID' => $row ['ID']
) );
$fraislivraison = "";
$garantie = "";
$reference = "";
$description = "";
foreach ( $productChildTemp as $rowChild ) {
$reference = $this->cleanUp ( $rowChild ['REFERENCE'] );
$description = $this->cleanUp ( $rowChild ['DESIGNATION'] );
$result = $rowChild ['ID'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $row ['IDCATEGORY'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Prix de revient
$result .= $rowChild ['PRIX'] . $this->_SEPARATOR;
$result .= $this->tva . $this->_SEPARATOR;
$result .= $description . $this->_SEPARATOR;
$result .= $reference . $this->_SEPARATOR; // Code barre
$result .= $this->_SEPARATOR; // Code unite
$result .= $this->_SEPARATOR; // Type d'article
$result .= $this->_SEPARATOR; // Code emplacement
$result .= $row ['IDBREND'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code �co
$fichier->Insertion ( $result );
}
}
$fichier->output ( 'ebp_articles' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
private function formatDate($datevalue) {
$date = new Zend_Date ();
$date->set ( $datevalue );
return $date->toString ( 'dd/MM/YYYY' );
}
private function getCommandDevisLine($listcommands) {
$commandLine = new CommandProduct ();
$fichier = new FichierExcel ();
$result = "Document - Num�ro du document;Document - Date;Document - Code client;Document - Nom du client;Document - Adresse 1 (facturation);Document - Code postal (facturation);Document - Ville (facturation);Document - Code Pays (facturation);Document - Nom (contact) (facturation);Document - Pr�nom (facturation);Document - T�l�phone fixe (facturation);Document - Fax (facturation);Document - E-mail (facturation);Document - Nom (adresse) (livraison);Document - Adresse 1 (livraison);Document - Code postal (livraison);Document - Ville (livraison);Document - Code Pays (livraison);Document - T�l�phone fixe (livraison);Document - Fax (livraison);Document - E-mail (livraison);Document - Frais de port HT;Document - Total Brut HT;Document - Total TTC;Document - Taux de TVA port;Ligne - Code article;Ligne - Quantit�;Ligne - Taux de TVA;Ligne - PV HT;Ligne - Montant Net HT;Ligne - Montant de remise unitaire HT cumul�";
$fichier->Colonne ( $result );
foreach ( $listcommands as $row ) {
$result = '"' . $row ['REFERENCE'] . '"' . $this->_SEPARATOR;
$result .= '"' . $this->formatDate ( $row ['DATESTART'] ) . '"' . $this->_SEPARATOR;
$result .= '"' . $row ['IDUSER'] . '"' . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['FACT_ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['FACT_CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['FACT_VILLE'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_TEL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_FAX'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_EMAIL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_RAISONSOCIAL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_VILLE'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_TEL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_FAX'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_EMAIL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['PRIXFRAISPORT'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['PRIXTOTALHTFP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['PRIXTOTALTTC'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $this->getCurrentTva ( $row ['DATESTART'] ) ) . $this->_SEPARATOR;
$selectLine = $commandLine->select ()->where ( "IDCOMMAND = " . $row ["ID"] );
$listLines = $commandLine->fetchAll ( $selectLine );
foreach ( $listLines as $rowLine ) {
$resultLine = $result;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDID'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDQUANTITY'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $this->getCurrentTva ( $row ['DATESTART'] ) ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDPRIX'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDPRIXTOTAL'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDPRIXREMISE'] ) . $this->_SEPARATOR;
$fichier->Insertion ( $resultLine );
}
}
return $fichier;
}
function exportcommandesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$command = new Command ();
$date = new Zend_Date ();
$date->addMonth ( - 3 );
$select = "
SELECT *
FROM command
WHERE isARCHIVE = 1
AND STATUT IN (1, 2, 3)
AND DATESTART >= '" . $date->toString ( 'YYYY-MM-dd' ) . "'";
$listcommands = $command->getAdapter ()->fetchAll ( $select );
$fichier = $this->getCommandDevisLine ( $listcommands );
$fichier->output ( 'ebp_commandes' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
function exportdevisAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$command = new Command ();
$date = new Zend_Date ();
$date->addMonth ( - 3 );
$select = "
SELECT *
FROM command
WHERE isARCHIVE = 1
AND STATUT IN (10, 11)
AND DATESTART >= '" . $date->toString ( 'YYYY-MM-dd' ) . "'";
$listcommands = $command->getAdapter ()->fetchAll ( $select );
$fichier = $this->getCommandDevisLine ( $listcommands );
$fichier->output ( 'ebp_devis' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
function importcategoriesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$nomTemp = 'csvfile';
if ($this->isValidCSVFile ( $nomTemp )) {
$nomOrigine = $_FILES [$nomTemp] ['name'];
$date = new Zend_Date ();
$nomDestination = "importcategories-" . $date->toString ( 'dd-MM-YYYY_HH-mm-ss' ) . ".csv";
if ($this->uploadCsvFile ( $_FILES [$nomTemp] ["tmp_name"], $nomDestination )) {
$header = array (
0 => 'ID',
1 => 'NOM',
2 => 'NOUSE1',
3 => 'NOUSE2',
4 => 'NOUSE3',
5 => 'NOUSE4',
6 => 'NOUSE5',
7 => 'NOUSE6'
);
$dataRows = $this->csv_to_array ( $this->csv_import . $nomDestination, $header );
if (sizeof ( $dataRows [0] ) == sizeof ( $header )) {
$category = new Category ();
$filesAdded = 0;
$filesUpdated = 0;
$filesError = 0;
foreach ( $dataRows as $row ) {
$id = $row ["ID"];
$nom = $this->cleanUp ( $row ["NOM"] );
$currentCat = $category->select ()->where ( "ID = ?", $id )->query ()->fetch ();
if ($currentCat != null && ! empty ( $currentCat )) {
try {
// Update
if ($currentCat ['NOM'] != $nom) {
$data = array (
'NOM' => $nom
);
$category->update ( $data, 'ID = ' . $id );
$filesUpdated ++;
}
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
} else {
try {
$navnom = $this->verifyNavigationString ( "", $nom, '' );
$keywords = $this->generateKeyWords ( $navnom );
// Insert
$data = array (
'NOM' => $nom,
'NAVTITRENOM' => $nom,
'DESCRIPTION' => $nom,
'NAVDESCRIPTION' => $nom,
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'IDPARENT' => 0
);
$category->insert ( $data );
$lastid = $category->getAdapter()->lastInsertId();
if ($lastid > 0) {
mkdir ("items/category/".$lastid, 0777);
mkdir ("items/product/".$lastid, 0777);
}
$filesAdded ++;
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
}
}
$this->view->messageSuccess = "Importation des fiches Familles articles<br/>
Fiches ajout�es : " . $filesAdded . "<br/>
Fiches modifi�es : " . $filesUpdated . "<br/>
Fiches non import�es : " . $filesError . "<br/>";
} else {
$this->view->messageError = "Le fichier n'est pas au format attendu pour les Familles articles";
}
} else {
$this->view->messageError = "Le fichier n'a pas pu etre import�.";
}
}
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
$this->render ( '/index' );
}
function importarticlesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$nomTemp = 'csvfile';
if ($this->isValidCSVFile ( $nomTemp )) {
$nomOrigine = $_FILES [$nomTemp] ['name'];
$date = new Zend_Date ();
$nomDestination = "importarticles-" . $date->toString ( 'dd-MM-YYYY_HH-mm-ss' ) . ".csv";
if ($this->uploadCsvFile ( $_FILES [$nomTemp] ["tmp_name"], $nomDestination )) {
$header = array (
0 => 'ID',
1 => 'NOM',
2 => 'IDCATEGORY',
3 => 'NOUSE1',
4 => 'PRIX',
5 => 'TVA',
6 => 'DESCRIPTION',
7 => 'REFERENCE',
8 => 'NOUSE2',
9 => 'NOUSE3',
10 => 'NOUSE4',
11 => 'IDBREND',
12 => 'NOUSE5'
);
$dataRows = $this->csv_to_array ( $this->csv_import . $nomDestination, $header );
if (sizeof ( $dataRows [0] ) == sizeof ( $header )) {
$product = new Product ();
$productLine = new ProductChild ();
$filesAdded = 0;
$filesUpdated = 0;
$filesError = 0;
$date = new Zend_Date ();
foreach ( $dataRows as $row ) {
$id = $row ["ID"];
$prix = $this->cleanUp ( $row ["PRIX"] );
$description = $this->cleanUp ( $row ["DESCRIPTION"] );
$reference = $this->cleanUp ( $row ["REFERENCE"] );
$tva = $this->cleanUp ( $row ["TVA"] );
$nom_prod = $this->cleanUp ( $row ["NOM"] );
$idCat_prod = $this->cleanUp ( $row ["IDCATEGORY"] );
$idbrend_prod = $this->cleanUp ( $row ["IDBREND"] );
$currentProdLine = $productLine->select ()->where ( "REFERENCE = ?", $reference )->query ()->fetch ();
if ($currentProdLine != null && ! empty ( $currentProdLine )) {
try {
// Update
$dataChild = array (
'DESIGNATION' => $description,
'PRIX' => $prix,
'DATEMODIF' => $date->toString ( 'YYYY-MM-dd HH:mm:ss' )
);
$productChild = new ProductChild ();
$productChild->update ( $dataChild, 'ID = ' . $id );
$filesUpdated ++;
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
} else {
try {
// Insert
$navnom = $this->verifyNavigationString ( "", $nom_prod, '' );
$keywords = $this->generateKeyWords ( $navnom );
$data = array (
'NOM' => $nom_prod,
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'NAVTITRE' => '',
'NAVDESC' => '',
'DESCRIPTIONSHORT' => $nom_prod,
'DESCRIPTIONLONG' => $nom_prod,
'PRIX' => $prix,
'isACTIVE' => 1,
'DATEPROMO' => $date->toString ( 'YYYY-MM-dd' ),
'isPROMO' => '1',
'IDCATEGORY' => $idCat_prod,
'ISSHOWBREND' => 1
);
$product->insert ( $data );
$lastId = $product->getAdapter ()->lastInsertId ();
$dataChild = array (
'REFERENCE' => $reference,
'DESIGNATION' => $description,
'PRIX' => $prix,
'ETATSTOCK' => 0,
'QUANTITYMIN' => 1,
'isDEVIS' => 1,
'IMAGEPROMO' => 0,
'DATEMODIF' => $date->toString ( 'YYYY-MM-dd HH:mm:ss' ),
'IDPRODUCT' => $lastId
);
$productChild = new ProductChild ();
$productChild->insert ( $dataChild );
$filesAdded ++;
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
}
}
$this->view->messageSuccess = "Importation des fiches Articles<br/>
Fiches ajout�es : " . $filesAdded . "<br/>
Fiches modifi�es : " . $filesUpdated . "<br/>
Fiches non import�es : " . $filesError . "<br/>";
} else {
$this->view->messageError = "Le fichier n'est pas au format attendu pour les Articles";
}
} else {
$this->view->messageError = "Le fichier n'a pas pu etre import�.";
}
}
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
$this->render ( '/index' );
}
var $csv_import = 'csvfiles/import/';
private function uploadCsvFile($tmpName, $destName) {
if (! file_exists ( $this->csv_import )) {
mkdir ( $this->csv_import, 0777, true );
}
return move_uploaded_file ( $tmpName, $this->csv_import . $destName );
}
private function isValidCSVFile($name) {
if (! empty ( $_FILES [$name] ) && ! empty ( $_FILES [$name] ['name'] )) {
$nomOrigine = $_FILES [$name] ['name'];
$elementsChemin = pathinfo ( $nomOrigine );
$extensionFichier = strtolower($elementsChemin ['extension']);
$extensionsAutorisees = array (
"csv"
);
if (! (in_array ( $extensionFichier, $extensionsAutorisees ))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue (.csv)";
} else {
return true;
}
} else {
$this->view->messageError = "Vous pouvez exporter les donn�es via EBP -> Outils -> Exportation de donn�es";
}
return false;
}
private function csv_to_array($filename = '', $header, $delimiter = ';') {
if (! file_exists ( $filename ) || ! is_readable ( $filename ))
return FALSE;
$data = array ();
if (($handle = fopen ( $filename, 'r' )) !== FALSE) {
while ( ($row = fgetcsv ( $handle, 1000, $delimiter )) !== FALSE ) {
if (! $header) {
$header = $row;
} else if (sizeof ( $header ) == sizeof ( $row )) {
$data [] = array_combine ( $header, $row );
}
}
fclose ( $handle );
}
return $data;
}
}
?>PK �0H[N�c�@ @ IndexController.phpnu &1i� <?php
class Backoffice_IndexController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->titlePage = "Vue d'ensemble";
}
function indexAction()
{
if ($this->isSiteGallery) {
$this->_redirect('/backoffice/category');
}
if ($this->isSiteEbusiness) {
$product = new Product();
$select = "
SELECT DISTINCT p.NOM NOM, p.DESCRIPTIONSHORT DESCRIPTIONSHORT, p.PRIX PRIX, p.ID ID, p.isACTIVE isACTIVE, p.isPROMO isPROMO
FROM product AS p
LEFT JOIN productchild AS pc ON pc.IDPRODUCT = p.ID
LEFT JOIN productchild_option AS pco ON pco.IDPRODUCTCHILD = pc.ID
LEFT JOIN product_option AS po ON po.IDPRODUCT = p.ID
WHERE (NOT EXISTS ( SELECT * FROM picture pic WHERE pic.IDPRODUCT = p.ID AND pic.POSITION = 1)
OR p.isACTIVE = 1 )";
$command = new Command();
$selectCommand = "
SELECT c.REFERENCE CMDREF,c.ID CMDID, c.PRIXTOTALTTC CMDTOTALTTC,c.PRIXTOTALHTFP CMDTOTALHTFP, c.PRIXFRAISPORTPOUR CMDFRAISPORTPOUR, c.PRIXFRAISPORT CMDFRAISPORT, c.PRIXTOTALHT CMDTOTALHT, c.PRIXTOTALHTHR CMDTOTALHTHR, c.PRIXREMISEEUR CMDREMISEEUR,
c.STATUT CMDSTATUT, c.DATESTART CMDDATESTART, c.DATEEND CMDDATEEND, c.LIV_RAISONSOCIAL CMDLIVRAISONSOCIAL, c.LIV_ADRESSE CMDLIVADRESSE, c.LIV_CP CMDLIVCP, c.LIV_VILLE CMDLIVVILLE,
c.LIV_PAYS CMDLIVPAYS, c.FACT_RAISONSOCIAL CMDFACTRAISONSOCIAL, c.FACT_ADRESSE CMDFACTADRESSE, c.FACT_CP CMDFACTCP , c.FACT_VILLE CMDFACTVILLE , c.FACT_PAYS CMDFACTPAYS,
cp.CHILDID CMDCHILDID, cp.CHILDREF CMDCHILDREF,cp.CHILDisPROMO CMDCHILDisPROMO, cp.CHILDPRIX CMDCHILDPRIX, cp.CHILDQUANTITY CMDCHILDQUANTITY, cp.CHILDPROMOPRIX CMDCHILDPROMOPRIX, cp.CHILDPRIXTOTAL CHILDPRIXTOTAL,
p.ID PRODUCTID, p.NOM PRODUCTNOM,
c.IDUSER IDUSER, c.USER_NOM USERNOM, c.USER_PRENOM USERPRENOM, c.USER_TEL USERTEL, c.USER_FAX USERFAX, c.USER_EMAIL USEREMAIL
FROM command c
LEFT JOIN command_product AS cp ON cp.IDCOMMAND = c.ID
LEFT JOIN product AS p ON p.ID = cp.PRODUCTID
LEFT JOIN productchild AS pc ON pc.ID = cp.CHILDID
WHERE c.STATUT = 1
GROUP BY c.REFERENCE
ORDER BY c.DATESTART ASC";
$selectDevis = "SELECT c.REFERENCE CMDREF,c.ID CMDID, c.PRIXTOTALTTC CMDTOTALTTC,c.PRIXTOTALHTFP CMDTOTALHTFP, c.PRIXFRAISPORTPOUR CMDFRAISPORTPOUR, c.PRIXFRAISPORT CMDFRAISPORT, c.PRIXTOTALHT CMDTOTALHT, c.PRIXTOTALHTHR CMDTOTALHTHR, c.PRIXREMISEEUR CMDREMISEEUR,
c.STATUT CMDSTATUT, c.DATESTART CMDDATESTART, c.DATEEND CMDDATEEND, c.LIV_RAISONSOCIAL CMDLIVRAISONSOCIAL, c.LIV_ADRESSE CMDLIVADRESSE, c.LIV_CP CMDLIVCP, c.LIV_VILLE CMDLIVVILLE,
c.LIV_PAYS CMDLIVPAYS, c.FACT_RAISONSOCIAL CMDFACTRAISONSOCIAL, c.FACT_ADRESSE CMDFACTADRESSE, c.FACT_CP CMDFACTCP , c.FACT_VILLE CMDFACTVILLE , c.FACT_PAYS CMDFACTPAYS,
cp.CHILDID CMDCHILDID, cp.CHILDREF CMDCHILDREF,cp.CHILDisPROMO CMDCHILDisPROMO, cp.CHILDPRIX CMDCHILDPRIX, cp.CHILDQUANTITY CMDCHILDQUANTITY, cp.CHILDPROMOPRIX CMDCHILDPROMOPRIX, cp.CHILDPRIXTOTAL CHILDPRIXTOTAL,
p.ID PRODUCTID, p.NOM PRODUCTNOM,
c.IDUSER IDUSER, c.USER_NOM USERNOM, c.USER_PRENOM USERPRENOM, c.USER_TEL USERTEL, c.USER_FAX USERFAX, c.USER_EMAIL USEREMAIL
FROM command c
LEFT JOIN command_product AS cp ON cp.IDCOMMAND = c.ID
LEFT JOIN product AS p ON p.ID = cp.PRODUCTID
LEFT JOIN productchild AS pc ON pc.ID = cp.CHILDID
WHERE c.STATUT = 10
GROUP BY c.REFERENCE
ORDER BY c.DATESTART ASC";
try {
$picture = new Picture();
$sql = $picture->fetchAll('POSITION = 1');
$listpics = array();
foreach ($sql as $row) {
$listpics[$row['IDPRODUCT']] = $row['URL'];
}
$this->view->listproductpicture = $listpics;
$this->view->statlistproduct = $product->getAdapter()->fetchAll($select);
$this->view->statlistcommand = $command->getAdapter()->fetchAll($selectCommand);
$this->view->statlistdevis = $command->getAdapter()->fetchAll($selectDevis);
} catch (Exception $e) {
$this->view->messageSuccess = "";
$this->view->messageError = $e->getMessage();
}
}
}
}
?>PK �0H[nѫ!W !W UserController.phpnu &1i� <?php
class Backoffice_UserController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "User";
$this->isConnectedWithRole('isUser');
}
function indexAction()
{
$this->_forward('/list');
}
function newsletterAction() {
$this->view->titlePage = "Envoyer une newsletter";
$userNewsletter = new UserNewsletter();
$listUser = $userNewsletter->select()->order('EMAIL ASC')->query()->fetchAll();
$this->view->listMail = $listUser;
$from = $this->newsletter_Mail;
$this->view->messageFrom = $from;
if ($this->getRequest()->isPost()) {
$body = $this->getRequest()->getPost('mailMessage');
$objet = $this->getRequest()->getPost('objetMessage');
$from = $this->getRequest()->getPost('fromMessage');
$this->view->messageBody = $body;
$this->view->messageObjet = $objet;
$this->view->messageFrom = $from;
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$validatorEmail = new Zend_Validate();
$validatorEmail -> addValidator(new Zend_Validate_EmailAddress());
if ($validator->isValid($body) && $validator->isValid($objet) && $validatorEmail->isValid($from)) {
if ($this->getRequest()->getPost('email') == 'All') {
foreach ($listUser as $row) {
$mail = new Zend_Mail();
$mess = $body;
//$mess = $body."<br><br> Pour vous d�sinscrire � la newsletter de ".$this->siteName.", <a href='XXXXXX/user/newsletter/nltr_quit/".$row['CODE']."' >cliquer ici</a>";
$mail->setBodyHtml($mess);
$mail->setFrom($from, $this->siteName);
$mail->addTo($row['EMAIL']);
$mail->setSubject($objet);
try {
$mail->send();
$this->log("Les emails ont �t� envoy�s",'info');
$this->view->messageSuccess = "Les emails ont �t� envoy�s";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Les emails n'ont pas �t� envoy�s";
}
}
} else {
$isExist = $userNewsletter->fetchRow("EMAIL = '".$this->getRequest()->getPost('email')."'");
if ($isExist) {
$mail = new Zend_Mail();
$mess = $body;
$mail->setBodyHtml($mess);
$mail->setFrom($from, $this->siteName);
$mail->addTo($isExist['EMAIL']);
$mail->setSubject($objet);
try {
$mail->send();
$this->view->messageSuccess = "L'email a �t� envoy�";
$this->log("L'email � �t� envoy� : ".$isExist['EMAIL'],'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "L'email n'a pas �t� envoy� : ".$isExist['EMAIL'];
}
}
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
foreach ($validatorEmail->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
}
function searchAction()
{
$this->view->titlePage = "Recherche avanc�e des clients";
$adminNamespace = $this->getSession();
$this->view->messageSuccess = "";
$this->view->messageError = "";
//Gestion des tris
$table = 'NOM';
$tri = 'ASC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triUserCol = $this->_request->getParam('col');
($adminNamespace->triUserSens == 'ASC') ? $adminNamespace->triUserSens = 'DESC' : $adminNamespace->triUserSens = 'ASC';
}
if (isset($adminNamespace->triUserCol)) {
$table = $adminNamespace->triUserCol;
$tri = $adminNamespace->triUserSens;
}
$this->view->listSearch = array();
if ($this->_request->isPost()) {
$post = $this->_request->getPost();
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
if ($validator->isValid($post['searchValue'])) {
$recherche = '%'.$post['searchValue'].'%';
$this->view->titlePage .= " : ".$post['searchValue'];
//Appel model pour listing
$user = new User();
$select = $user->select()
->where('NOM LIKE ? ',$recherche)
->orWhere('PRENOM LIKE ? ',$recherche)
->orWhere('TEL LIKE ? ',$recherche)
->orWhere('ADRESSE LIKE ? ',$recherche)
->orWhere('EMAIL LIKE ? ',$recherche)
->order($table.' '.$tri);
$listusers = $user->fetchAll($select);
$adminNamespace->searchUsers = $listusers;
$this->view->listSearch = $listusers;
if (count($listusers) == 0) {
$this->view->messageError = "Aucun resultats";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
}
} else {
if (isset($adminNamespace->searchUsers) && !empty($adminNamespace->searchUsers)) {
$this->view->listSearch = $adminNamespace->searchUsers;
}
}
}
function editAction() {
$this->view->titlePage = "Modifier un client";
$codeIntern = new CodeIntern();
$this->view->listCodeIntern = $codeIntern->fetchAll();
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
$user = new User();
$row = $user->getUserByID($id);
$carteFidelite = new CarteFidelite();
$this->view->listcommandfidelite = $carteFidelite->getCommandUserCarteFidelite($id);
$this->view->userfidelite = $carteFidelite->getInfosByUser($id);
$this->view->populateForm = $row;
$this->getRemiseClient($row['ID'], $row['CODEINTERN']);
$userCaddyType = new UserCaddyType();
$this->view->caddyType = $userCaddyType->computeCaddyTypeByUser($row['ID'], true);
}
}
function edituserAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$validatorEmail = new Zend_Validate_EmailAddress();
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'ID' => $filter->filter($params['id']),
'NOM' => $filter->filter($params['lastname']),
'PRENOM' => $filter->filter($params['firstname']),
'CIVILITE' => $filter->filter($params['civility']),
'FONCTION' => $filter->filter($params['fct']),
'RAISONSOCIAL' => $filter->filter($params['raisonsocial']),
'ADRESSECOMPLETE' => $filter->filter($params['adressecomplete']),
'ADRESSE' => $filter->filter($params['adresse']),
'CP' => $filter->filter($params['cp']),
'VILLE' => $filter->filter($params['ville']),
'PAYS' => $filter->filter($params['pays']),
'DEPARTEMENT' => $filter->filter($params['departement']),
'REGION' => $filter->filter($params['region']),
'EMAIL' => $filter->filter($params['email']),
'TEL' => $filter->filter($params['tel']),
'FAX' => $filter->filter($params['fax']),
'NUMCOMPTE' => $filter->filter($params['numcompte']),
'SIRET' => $filter->filter($params['siret']),
'NUMIDFISC' => $filter->filter($params['numidfisc']),
'CODEAPE' => $filter->filter($params['codeape']),
'SECTACTIVITE' => $filter->filter($params['sectactivite']),
'COMMENTAIRE' => $filter->filter($params['comm']),
'CODEINTERN' => $filter->filter($params['cintern']),
'MODEPAIEMENT' => $filter->filter($params['modepaiement']),
'TYPE' => $filter->filter($params['typeuser']),
'isCREDIT' => $filter->filter($params['iscredit']),
'isRECEPFACTURE' => $filter->filter($params['isrecepfacture']));
if ($validator->isValid($data['NOM']) &&
$validator->isValid($data['PRENOM']) &&
$validator->isValid($data['ADRESSE']) &&
$validator->isValid($data['CP']) &&
$validator->isValid($data['VILLE']) &&
$validator->isValid($data['PAYS']) &&
$validatorEmail->isValid($data['EMAIL'])
) {
try {
$id = $data['ID'];
if ( $id > 0) {
$user = new User();
$user->update($data, 'ID = '.$id);
$this->log("Mise a jour de l'utilisateur : ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "L'email existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
foreach ($validatorEmail->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('edit');
}
function getRemiseClient($id, $codeintern) {
$promoUser = new PromoUser();
$listUser = $promoUser->getRemiseByUserIDFull($id);
if ($listUser) { $this->view->listUser = $listUser; }
$listUserBrend = $promoUser->getRemiseByMarqueFull($id);
if ($listUserBrend) {
$this->view->listUserBrend = $listUserBrend;
}
$listCinternBrend = $promoUser->getRemiseByCodeInternMarqueFull($codeintern);
if ($listCinternBrend) {
$this->view->listCinternBrend = $listCinternBrend;
}
}
function guestAction()
{
if ($this->FeatureProductSendDetail || $this->FeatureProductDocumentDownloadGuest) {
$this->view->titlePage = "Gestion des invit�s";
$userGuest = new UserGuest();
$select = $userGuest->select()->order('DATEINSERT desc');
$listusers = $userGuest->fetchAll($select);
$this->setPaginator($listusers, $this->_getParam('page',1), 50);
} else {
$this->_forward('/list');
}
}
function listAction()
{
$this->view->titlePage = "Gestion des clients";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'NOM';
$tri = 'ASC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triUserCol = $this->_request->getParam('col');
($adminNamespace->triUserSens == 'ASC') ? $adminNamespace->triUserSens = 'DESC' : $adminNamespace->triUserSens = 'ASC';
}
if (isset($adminNamespace->triUserCol)) {
$table = $adminNamespace->triUserCol;
$tri = $adminNamespace->triUserSens;
}
//Appel model pour listing
$user = new User();
$select = $user->select()
->order($table.' '.$tri);
$listusers = $user->fetchAll($select);
$this->setPaginator($listusers, $this->_getParam('page',1), 50);
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$user = new User();
$user->delete('ID = '.$id);
$this->view->messageSuccess = "L'utilisateur a ete supprime";
$this->log("L'utilisateur a ete supprime ",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
function banAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$user = new User();
$data = array (
'isBAN' => (int)$this->_request->getParam('ban'));
$user->update($data, 'ID = '.$id);
if ($data['isBAN']==0) {
$this->view->messageSuccess = "L'utilisateur ne peut plus se connecter";
$this->log("L'utilisateur ne peut plus se connecter : ".$id,'info');
} else {
$this->view->messageSuccess = "L'utilisateur peut se connecter";
$this->log("L'utilisateur peut se connecter ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
function codeinterneAction() {
$this->view->titlePage = "Gestion des codes internes";
$codeintern = new CodeIntern();
if ($this->_request->isPost() && (int)$this->_request->getParam('id') ==0) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$data = array (
'CODE' => $filter->filter($params['code']),
'LABEL' => $filter->filter($params['label'])
);
if ($validator->isValid($data['CODE']) && $validator->isValid($data['LABEL'])) {
try {
$codeintern->insert($data);
$this->view->messageSuccess = "Le code interne a �t� ajout�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le code interne existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->view->listcodeintern = $codeintern->select()->order('CODE ASC')->query()->fetchAll();
}
function codeinterneeditAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$codeintern = new CodeIntern();
//get the form params
$params = $this->_request->getPost();
$data = array (
'CODE' => $filter->filter($params['code']),
'LABEL' => $filter->filter($params['label']),
'ID' => $filter->filter($params['id'])
);
if ($validator->isValid($data['CODE']) && $validator->isValid($data['LABEL'])
) {
try {
$codeintern->update($data, 'ID = '.$data['ID']);
$this->view->messageSuccess = "Le code interne a �t� modifi�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Le code interne existe d�j�";
$this->_forward('codeinterne');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('codeinterne');
}
function codeinternedelAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$codeintern = new CodeIntern();
$sql = 'SELECT u.NOM NOM, u.PRENOM PRENOM, u.ID IDUSER, uci.ID IDCODEINTERN, uci.CODE CODEINTERN
FROM user_cintern uci
LEFT JOIN user AS u ON u.CODEINTERN = uci.ID
WHERE u.CODEINTERN = '.$id ;
$isExistCode = $codeintern->getAdapter()->fetchRow($sql);
if (!$isExistCode) {
$codeintern->delete('ID = '.$id);
$this->view->messageSuccess = "Le code interne a �t� supprim�";
} else {
$this->view->messageError = "Le code interne est utilis� par : <b>".$isExistCode['NOM']." ".$isExistCode['PRENOM']."</b>";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
$this->_forward('codeinterne');
}
}
}
$this->_forward('codeinterne');
}
function panieraddAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$params = $this->getRequest()->getPost();
$productChild = new ProductChild();
$reference = $filter->filter($params['reference']);
$remiseeuro = (int)$params['remiseeuro'];
$remisepour = (int)$params['remisepour'];
$id = (int)$params['id'];
$isOK = true;
if ($remiseeuro > 0 && $remisepour > 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($remiseeuro == 0 && $remisepour == 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE et est obligatoire. ";
$isOK = false;
}
if (($validator->isValid($remiseeuro) || $validator->isValid($remisepour)) && $isOK == true && $validator->isValid($reference)) {
$isExistChild = $productChild->fetchRow("REFERENCE = '".$reference."'");
if ($isExistChild) {
$userCaddyType = new UserCaddyType();
$isExistCaddy = $userCaddyType->fetchRow("REFERENCE = '".$reference."' AND USERID = ".$id);
if ($isExistCaddy) {
$data = array (
'REFERENCE' => $reference,
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'isACTIF' => 'Y'
);
$userCaddyType->update($data, "REFERENCE = '".$reference."' AND USERID = ".$id);
} else {
$data = array (
'REFERENCE' => $reference,
'USERID' => $id,
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'isACTIF' => 'Y'
);
$userCaddyType->insert($data);
}
$this->view->messageSuccess = "La r�f�rence : ".$data['REFERENCE']." a �t� ajout�e. ";
} else {
$this->view->messageError = "La r�f�rence : <b>".$reference."</b> n'existe pas. ";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/edit');
}
function paniereditAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$params = $this->getRequest()->getPost();
$idcaddy = (int)$params['idcaddy'];
$iduser = (int)$params['id'];
$remiseeuro = (int)$params['remiseeuro'];
$remisepour = (int)$params['remisepour'];
$isOK = true;
if ($remiseeuro > 0 && $remisepour > 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($isOK == true && $idcaddy > 0) {
$userCaddyType = new UserCaddyType();
$data = array ('REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'isACTIF' => 'Y');
$userCaddyType->update($data, "ID = ".$idcaddy);
$this->view->messageSuccess = "La r�f�rence a �t� modifi�e. ";
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/edit');
}
function panierdelAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
if ($this->_request->isPost()) {
$params = $this->getRequest()->getPost();
$idcaddy = (int)$params['idcaddy'];
if ($idcaddy > 0) {
try {
$userCaddyType = new UserCaddyType();
$result = $userCaddyType->delete("ID = ".$idcaddy);
$this->view->messageSuccess = "L'article du panier a �t� supprim�";
$this->log("L'article du panier a �t� supprim�",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
function panieractiveAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
if ($this->_request->isPost()) {
$params = $this->getRequest()->getPost();
$idcaddy = (int)$params['idcaddy'];
if ($idcaddy > 0) {
try {
$userCaddyType = new UserCaddyType();
$data = array ( 'isACTIF' => $params['isActif'] );
$result = $userCaddyType->update($data, "ID = ".$idcaddy);
$this->view->messageSuccess = "L'article du panier a �t� modifi�";
$this->log("L'article du panier a �t� modifi�",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
function panieractiveallAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
if ($this->_request->isPost()) {
$params = $this->getRequest()->getPost();
$idUser = (int)$params['id'];
if ($idUser > 0) {
try {
$user = new User();
$data = array ( 'isCADDYTYPE' => $params['isActif'] );
$result = $user->update($data, "ID = ".$idUser);
$this->view->messageSuccess = "Les articles du panier ont �t� modifi�s";
$this->log("Les articles du panier ont �t� modifi�s",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/edit');
}
}
?>PK �0H[v2+��M �M SupplierController.phpnu &1i� <?php
class Backoffice_SupplierController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Supplier";
$this->isConnectedWithRole('isSupplier');
}
function indexAction()
{
$this->_forward('/list');
}
function searchAction()
{
$this->view->titlePage = "Rechercher un Fournisseur";
$adminNamespace = $this->getSession();
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$recherche = '%'.$post['searchValue'].'%';
$this->view->titlePage .= " : ".$post['searchValue'];
//Appel model pour listing
$supplier = new Supplier();
$supplierBrend = new SupplierBrend();
if ($post['searchType'] != 'BREND') {
$select = $supplier->select()
->where($post['searchType'].' LIKE ? ',$recherche)
->order($post['searchType'].' ASC ');
$listsuppliers = $supplier->fetchAll($select)->toArray();
} else {
$select = "SELECT s.*
FROM supplier AS s
LEFT JOIN supplier_brend AS sb ON sb.IDSUPPLIER = s.ID";
if (!empty($post['searchType'])) {
$select .= " WHERE sb.".$post['searchType']." LIKE '".$recherche."' ";
}
$select .= " ORDER BY BREND ASC";
$listsuppliers = $supplier->getAdapter()->fetchAll($select);
}
$this->view->listsupplierCount = count($listsuppliers);
$this->view->listsupplier = $listsuppliers;
if ($this->view->listsupplierCount == 0) {
$this->view->messageError = "Aucun resultats";
}
}
}
function editbrendAction () {
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->getRequest()->getPost();
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(2));
$isShowBrendPage = (int)$params['isshowbrendpage'];
//Refractor the params
$dataBrend = array (
'BREND' => $filter->filter($params['brend']),
'IS_SHOW_BREND_PAGE' => $isShowBrendPage
);
$supplierBrend = new SupplierBrend();
$supplier = new Supplier();
if ($validator->isValid($dataBrend['BREND'])) {
try {
$isExistBrend = $supplierBrend->fetchRow("BREND LIKE '".$dataBrend['BREND']."' AND ID <> ".$params['idBrend']);
if (!$isExistBrend) {
$supplierBrend->update($dataBrend, 'ID = '.$params['idBrend']);
$this->view->messageSuccess = "La marque a �t� modif�e";
} else {
$this->view->messageError = "La marque existe d�j�";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La marque existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
}
$this->view->populateFormSupplier = $supplier->fetchRow('ID = '.$params['id']);
$this->view->populateFormBrend = $supplierBrend->fetchAll('IDSUPPLIER = '.$params['id'])->toArray();
}
$this->render('/edit');
}
function addbrendAction () {
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->getRequest()->getPost();
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(2));
//Refractor the params
$dataBrend = array (
'BREND' => $filter->filter($params['brend']),
'IDSUPPLIER' => $filter->filter($params['id']),
'URL' => ''
);
$supplierBrend = new SupplierBrend();
$supplier = new Supplier();
if ($validator->isValid($dataBrend['BREND'])) {
try {
$isExistBrend = $supplierBrend->fetchRow("BREND LIKE '".$dataBrend['BREND']."'");
if (!$isExistBrend) {
if (!empty($_FILES['picture']['name'])) {
$url = $this->uploadNewPicsGetURL('picture');
if ($url != false) {
$dataBrend['URL'] = $url;
}
}
$supplierBrend->insert($dataBrend);
$this->view->messageSuccess = "La marque a �t� ajout�e";
} else {
$this->view->messageError = "La marque existe d�j�";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La marque existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
}
$this->view->populateFormSupplier = $supplier->fetchRow('ID = '.$params['id']);
$this->view->populateFormBrend = $supplierBrend->fetchAll('IDSUPPLIER = '.$params['id'])->toArray();
}
$this->render('/edit');
}
function delbrendAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
$supplier = new Supplier();
$supplierBrend = new SupplierBrend();
if ($this->getRequest()->isPost('delBrendForm')) {
$params = $this->getRequest()->getPost();
try {
$product = new Product();
$isExistProduct = $product->fetchRow("IDBREND = ".$params['idBrend']);
if (!$isExistProduct) {
$supplierBrend->delete('ID = '.$params['idBrend']);
$this->view->messageSuccess = "La marque a �t� supprim�e";
} else {
$this->view->messageError = "La marque est utilis�e par un produit : <b>".$isExistProduct['NOM']."</b>";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
$this->view->populateFormSupplier = $supplier->fetchRow('ID = '.$params['id']);
$this->view->populateFormBrend = $supplierBrend->fetchAll('IDSUPPLIER = '.$params['id'])->toArray();
}
$this->render('/edit');
}
function editAction()
{
$this->view->titlePage = "Modifier un fournisseur";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$validatorEmail = new Zend_Validate_EmailAddress();
$supplier = new Supplier();
$supplierBrend = new SupplierBrend();
if ($this->getRequest()->isPost() && $this->getRequest()->getPost('company')) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataSupplier = array (
'NOM' => $filter->filter($params['nom']),
'PRENOM' => $filter->filter($params['prenom']),
'COMPANY' => $filter->filter($params['company']),
'ADDRESSE' => $filter->filter($params['address']),
'CP' => $filter->filter($params['cp']),
'VILLE' => $filter->filter($params['ville']),
'EMAIL' => $filter->filter($params['email']),
'TEL' => $filter->filter($params['tel']),
'FAX' => $filter->filter($params['fax']),
'DESCRIPTIONSHORT' => $filter->filter($params['descshort']),
'DESCRIPTIONLONG' => $params['desclong']
);
if ($validator->isValid($dataSupplier['NOM']) &&
$validator->isValid($dataSupplier['PRENOM']) &&
$validator->isValid($dataSupplier['COMPANY']) &&
$validatorEmail->isValid($dataSupplier['EMAIL'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$isExistSupplier = $supplier->fetchRow("COMPANY LIKE '".$dataSupplier['COMPANY']."' AND ID <> ".$id);
if (!$isExistSupplier) {
$url = $this->uploadNewPicsGetURL('picture');
if ($url != false) {
$dataSupplier['URL'] = $url;
$supplier->update($dataSupplier,'ID = '.$id);
$this->view->messageSuccess = "Le fournisseur a �t� modifi�, l'image a �t� upload�e";
} else {
$supplier->update($dataSupplier, 'ID = '.$id);
$this->view->messageSuccess = "Le fournisseur a �t� modifi�";
}
} else {
$this->view->messageError= "Le fournisseur existe d�j�";
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormSupplier = $dataSupplier;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
foreach ($validatorEmail->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormSupplier = $dataSupplier;
}
}
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
}
if ($this->getRequest()->isPost('addBrendForm') ||
$this->getRequest()->isPost('editSupplierForm')
) {
$params = $this->_request->getPost();
$id = $params['id'];
}
if ($id>0) {
$this->view->populateFormSupplier = $supplier->fetchRow('ID = '.$id);
$this->view->populateFormBrend = $supplierBrend->fetchAll('IDSUPPLIER = '.$id)->toArray();
}
}
function addAction()
{
$this->view->titlePage = "Ajouter un fournisseur";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost('addSupplierForm')) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//valideurs pour FILE
$validatorFile = new Zend_Validate();
$validatorFile -> addValidator(new Zend_Validate_File_Exists())
-> addValidator(new Zend_Validate_File_IsImage());
$validatorEmail = new Zend_Validate_EmailAddress();
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataSupplier = array (
'NOM' => $filter->filter($params['lastname']),
'PRENOM' => $filter->filter($params['firstname']),
'COMPANY' => $filter->filter($params['company']),
'ADDRESSE' => $filter->filter($params['address']),
'CP' => $filter->filter($params['cp']),
'VILLE' => $filter->filter($params['ville']),
'EMAIL' => $filter->filter($params['email']),
'TEL' => $filter->filter($params['tel']),
'FAX' => $filter->filter($params['fax']),
'URL' => ''
);
$dataBrend = array (
'BREND' => $filter->filter($params['brend']),
'URL' => '',
'IDSUPPLIER' => ''
);
if (
$validator->isValid($dataBrend['BREND']) &&
$validator->isValid($dataSupplier['NOM']) &&
$validator->isValid($dataSupplier['PRENOM']) &&
$validator->isValid($dataSupplier['COMPANY']) &&
$validatorEmail->isValid($dataSupplier['EMAIL'])
) {
try {
$supplier = new Supplier();
$supplierBrend = new SupplierBrend();
$isExistBrend = $supplierBrend->fetchRow("BREND LIKE '".$dataBrend['BREND']."'");
$isExistSupplier = $supplier->fetchRow("COMPANY LIKE '".$dataSupplier['COMPANY']."'");
if (!$isExistBrend && !$isExistSupplier) {
$url = $this->uploadNewPicsGetURL('picture');
if ($url != false) {
$dataBrend['URL'] = $url;
$dataSupplier['URL'] = $url;
}
$supplier->insert($dataSupplier);
$lastid = $supplier->getAdapter()->lastInsertId();
$dataBrend['IDSUPPLIER'] = $lastid;
$supplierBrend->insert($dataBrend);
$this->view->messageSuccess = "Le fournisseur a �t� ajout�";
} else {
$this->view->messageError = "La marque ou le fournisseur existe d�j�";
$this->view->populateFormSupplier = $dataSupplier;
$this->view->populateFormBrend = $dataBrend;
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormSupplier = $dataSupplier;
$this->view->populateFormBrend = $dataBrend;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
foreach ($validatorEmail->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
foreach ($validatorFile->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormSupplier = $dataSupplier;
$this->view->populateFormBrend = $dataBrend;
}
}
}
function listAction()
{
$this->view->titlePage = "Gestion des fournisseurs";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'COMPANY';
$tri = 'ASC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triSupplierCol = $this->_request->getParam('col');
($adminNamespace->triSupplierSens == 'ASC') ? $adminNamespace->triSupplierSens = 'DESC' : $adminNamespace->triSupplierSens = 'ASC';
}
if (isset($adminNamespace->triSupplierCol)) {
$table = $adminNamespace->triSupplierCol;
$tri = $adminNamespace->triSupplierSens;
}
//Appel model pour listing
$supplier = new Supplier();
$sql = "SELECT s.ID ID, s.COMPANY COMPANY,s.NOM NOM, s.PRENOM PRENOM, s.ADDRESSE ADDRESSE, s.CP CP, s.VILLE VILLE, s.EMAIL EMAIL, s.TEL TEL, s.FAX FAX,
s.URL URL
FROM supplier AS s
ORDER BY ".$table." ".$tri;
$result = $supplier->getAdapter()->fetchAll($sql);
$this->view->listsupplier = $result;
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$product = new Product();
$supplier = new Supplier();
$supplierBrend = new SupplierBrend();
$sql = "
SELECT DISTINCT p.NOM NOMPRODUCT , sb.BREND BREND
FROM product AS p
LEFT JOIN supplier_brend AS sb ON sb.ID = p.IDBREND
LEFT JOIN supplier AS s ON s.ID = sb.IDSUPPLIER
WHERE s.ID = ".$id;
$isExistProduct = $product->getAdapter()->fetchRow($sql);
if (!$isExistProduct) {
$supplier->delete('ID = '.$id);
$supplierBrend->delete('IDSUPPLIER = '.$id);
$this->view->messageSuccess = "Le fournisseur a �t� supprim�";
} else {
$this->view->messageError = "La marque : <b>".$isExistProduct['BREND']."</b> poss�de des produits : <b>".$isExistProduct['NOMPRODUCT']."</b>";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
function uploadNewPicsGetURL($nomTemp) {
if(!empty($_FILES[$nomTemp]) && !empty($_FILES[$nomTemp]['name'])) {
$nomOrigine = $_FILES[$nomTemp]['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpg", "jpeg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
$repertoireDestination = 'items/supplier/';
$this->checkDirectoryExist($repertoireDestination);
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
$fileoriginal = $repertoireDestination.$nomDestination;
if (move_uploaded_file($_FILES[$nomTemp]["tmp_name"],$fileoriginal)) {
//Resize picture
$info = getimagesize($fileoriginal) ;
list($width_old, $height_old) = $info;
$maxwidth = $this->FeaturePictureResizeWidth;
$maxheight = $this->FeaturePictureResizeHeight;
if ($width_old > $maxwidth || $height_old > $maxheight) {
Utils_Tool::smart_resize_image($fileoriginal , null, $maxwidth , $maxheight , true , $fileoriginal , true , false ,50 );
}
$data = array (
'URL' => $fileoriginal
);
return $data['URL'];
} else {
return false;
}
}
}
return false;
}
function setpictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
$supplier = new Supplier();
$supplierBrend = new SupplierBrend();
try {
$data = array (
'URL' => $params['picture']
);
if ((int)$params['idSelected']>0) {
$supplierBrend->update($data,'ID = '.$params['idSelected']);
$this->view->messageSuccess = "L'image de la marque a �t� modifi�e";
} else {
$this->view->messageError = "Vous devez selectionner une marque";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
$this->view->populateFormSupplier = $supplier->fetchRow('ID = '.$params['id']);
$this->view->populateFormBrend = $supplierBrend->fetchAll('IDSUPPLIER = '.$params['id'])->toArray();
}
$this->render('/edit');
}
function erasepictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
$product = new Product();
$supplier = new Supplier();
$supplierBrend = new SupplierBrend();
try {
$sql = "
SELECT DISTINCT p.NOM NOMPRODUCT , sb.BREND BREND
FROM product AS p
LEFT JOIN supplier_brend AS sb ON sb.ID = p.IDBREND
LEFT JOIN supplier AS s ON s.ID = sb.IDSUPPLIER
WHERE sb.URL = '".$params['picture']."'";
$isExistProduct = $product->getAdapter()->fetchRow($sql);
if (!$isExistProduct) {
unlink($params['picture']);
$data = array (
'URL' => ''
);
$supplierBrend->update($data,"URL = '".$params['picture']."'");
$this->view->messageSuccess = "L'image a �t� supprim�e d�finitivement";
} else {
$this->view->messageError = "La marque : <b>".$isExistProduct['BREND']."</b> poss�de des produits : <b/>".$isExistProduct['NOMPRODUCT']."</b>";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
$this->view->populateFormSupplier = $supplier->fetchRow('ID = '.$params['id']);
$this->view->populateFormBrend = $supplierBrend->fetchAll('IDSUPPLIER = '.$params['id'])->toArray();
}
$this->render('/edit');
}
}
?>PK �0H[�8ڻ � AnnoncefooterController.phpnu &1i� <?php
class Backoffice_AnnoncefooterController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Gestion des annonces en bas de page";
$this->view->currentMenu = "AnnonceFooter";
$this->isConnectedWithRole('isPromo');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$annonce = new AnnonceFooter();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonceFooter = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow'],
'CONT_NAME' => '',
'CAT_ID' => ''
);
if (isset($params['controllername'])) {
foreach($params['controllername'] as $value)
{
$dataAnnonce['CONT_NAME'] .= $value.";";
}
}
if (isset($params['categorie'])) {
foreach($params['categorie'] as $value)
{
$dataAnnonce['CAT_ID'] .= $value.";";
}
}
if ($validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� modifi�e";
$this->view->populateFormAnnonceFooter = $annonce->fetchRow('ID = '.$id);
$this->log("L'annonce a �t� modifi�e ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceFooter = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceFooter = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function addAction()
{
$this->view->titlePage = "Ajouter une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow'],
'CONT_NAME' => '',
'CAT_ID' => ''
);
if (isset($params['controllername'])) {
foreach($params['controllername'] as $value)
{
$dataAnnonce['CONT_NAME'] .= $value.";";
}
}
if (
$validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$annonce = new AnnonceFooter();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "L'annonce a �t� ajout�e";
$this->log("L'annonce a �t� ajout�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceFooter = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceFooter = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function listAction()
{
$this->view->titlePage = "Gestion des annonces en bas de page";
//Appel model pour listing
$annonces = new AnnonceFooter();
$result = $annonces->select()->order('isSHOW ASC')->order('TITRE ASC')->query()->fetchAll();
$this->view->listannoncefooter = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceFooter();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� supprim�e";
$this->log("L'annonce a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[7�zb/ / AnnonceController.phpnu &1i� <?php
class Backoffice_AnnonceController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->isConnectedWithRole('isPromo');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier une Annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$annonce = new AnnonceContent();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow']
);
if ($validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� modifi�e";
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
}
} catch (Zend_Exception $e) {
$this->view->populateFormAnnonce = $dataAnnonce;
$this->log($e->getMessage(),'err');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function addAction()
{
$this->view->titlePage = "Ajouter une Annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow']
);
if (
$validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$annonce = new AnnonceContent();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "L'annonce a �t� ajout�e";
} catch (Zend_Exception $e) {
$this->view->populateFormAnnonce = $dataAnnonce;
$this->log($e->getMessage(),'err');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function listAction()
{
$this->view->titlePage = "Listing des Annonces";
$adminNamespace = $this->getSession();
//Appel model pour listing
$annonces = new AnnonceContent();
$result = $annonces->select()->order('isSHOW ASC')->order('TITRE ASC')->query()->fetchAll();
$this->view->listannonce = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceContent();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� supprim�e";
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[���=U( U( ProductglobalController.phpnu &1i� <?php
class Backoffice_ProductglobalController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Promos";
$this->isConnectedWithRole('isAdmin');
}
function indexAction()
{
$this->_forward('/list');
}
public function listAction() {
$this->view->titlePage = "G�n�ralit�s";
$promoCommand = new PromoCommand();
$isFrais = $promoCommand->fetchAll('MONTANTFRAISCMD > 0 AND MONTANTFRAISCMD IS NOT NULL','MONTANTFRAISCMD ASC');
if ($isFrais) {
$this->view->remiseFrais = $isFrais;
}
$isValide = $promoCommand->fetchRow('MONTANTVALID > 0 AND MONTANTVALID IS NOT NULL');
if ($isValide) {
$this->view->validCommand = $isValide;
}
$supplierBrend = new SupplierBrend();
$this->view->listbrend = $supplierBrend->fetchAll($supplierBrend->select()->order('BREND ASC'));
}
public function addpricecategoryAction() {
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$idCatSelected = $params['listcategory'];
$pricesign = $params['pricesign'];
$pricepour = $params['pricepour'];
if ($idCatSelected != 'none') {
$pricepour = intval($pricepour);
if ($pricepour > 0) {
$category = new Category();
$dataID = "";
if ($idCatSelected == 0) {
$data = $category->fetchAll();
foreach ($data as $row) {
if ($dataID == "") {
$dataID = $row['ID'];
} else {
$dataID .= " , ".$row['ID'];
}
}
} else {
$dataID = $category->getAllSubsIDByIDToString($idCatSelected);
}
$product = new Product();
$productChild = new ProductChild();
$listProducts = $product->fetchAll('IDCATEGORY IN ('.$dataID.')');
foreach ($listProducts as $rowProduct) {
$actualProductPrice = $rowProduct['PRIX'];
if ($pricesign == '+') {
$newProductPrice = $rowProduct['PRIX'] + (($rowProduct['PRIX'] * $pricepour) / 100);
} else {
$newProductPrice = $rowProduct['PRIX'] - (($rowProduct['PRIX'] * $pricepour) / 100);
}
$newProductPrice = sprintf("%.2f",$newProductPrice);
$dataProductUpdated = array();
$dataProductUpdated['PRIX'] = $newProductPrice;
$product->update($dataProductUpdated,'ID = '.$rowProduct['ID']);
$listChilds = $productChild->fetchAll('IDPRODUCT = '.$rowProduct['ID']);
foreach ($listChilds as $rowChild) {
$actualPrice = $rowChild['PRIX'];
if ($pricesign == '+') {
$newPrice = $rowChild['PRIX'] + (($rowChild['PRIX'] * $pricepour) / 100);
} else {
$newPrice = $rowChild['PRIX'] - (($rowChild['PRIX'] * $pricepour) / 100);
}
$newPrice = sprintf("%.2f",$newPrice);
$dataChildUpdated = array();
$dataChildUpdated['PRIX'] = $newPrice;
$productChild->update($dataChildUpdated,'ID = '.$rowChild['ID']);
}
}
if ($pricesign == '+') {
$this->view->messageSuccess = "Les produits ont �t� augment�s de ".$pricesign.$pricepour." % ";
} else {
$this->view->messageSuccess = "Les produits ont �t� diminu�s de ".$pricesign.$pricepour." % ";
}
} else {
$this->view->messageError = "Le pourcentage doit �tre sup�rieur � 0";
}
} else {
$this->view->messageError = "Une cat�gorie doit �tre s�lectionn�e";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('list');
}
public function addpricebrendAction() {
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$idBrendSelected = $params['listbrend'];
$pricesign = $params['pricesign'];
$pricepour = $params['pricepour'];
if ($idBrendSelected != 'none') {
$pricepour = intval($pricepour);
if ($pricepour > 0) {
$product = new Product();
$productChild = new ProductChild();
$listProducts = $product->fetchAll('IDBREND = '.$idBrendSelected);
foreach ($listProducts as $rowProduct) {
$actualProductPrice = $rowProduct['PRIX'];
if ($pricesign == '+') {
$newProductPrice = $rowProduct['PRIX'] + (($rowProduct['PRIX'] * $pricepour) / 100);
} else {
$newProductPrice = $rowProduct['PRIX'] - (($rowProduct['PRIX'] * $pricepour) / 100);
}
$newProductPrice = sprintf("%.2f",$newProductPrice);
$dataProductUpdated = array();
$dataProductUpdated['PRIX'] = $newProductPrice;
$product->update($dataProductUpdated,'ID = '.$rowProduct['ID']);
$listChilds = $productChild->fetchAll('IDPRODUCT = '.$rowProduct['ID']);
foreach ($listChilds as $rowChild) {
$actualPrice = $rowChild['PRIX'];
if ($pricesign == '+') {
$newPrice = $rowChild['PRIX'] + (($rowChild['PRIX'] * $pricepour) / 100);
} else {
$newPrice = $rowChild['PRIX'] - (($rowChild['PRIX'] * $pricepour) / 100);
}
$newPrice = sprintf("%.2f",$newPrice);
$dataChildUpdated = array();
$dataChildUpdated['PRIX'] = $newPrice;
$productChild->update($dataChildUpdated,'ID = '.$rowChild['ID']);
}
}
if ($pricesign == '+') {
$this->view->messageSuccess = "Les produits ont �t� augment�s de ".$pricesign.$pricepour." % ";
} else {
$this->view->messageSuccess = "Les produits ont �t� diminu�s de ".$pricesign.$pricepour." % ";
}
} else {
$this->view->messageError = "Le pourcentage doit �tre sup�rieur � 0";
}
} else {
$this->view->messageError = "Une marque doit �tre s�lectionn�e";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('list');
}
function commandaddAction() {
try {
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$promoCommand = new PromoCommand();
$productChild = new ProductChild();
$params = array();
$params = $this->getRequest()->getPost();
if ($params['remise'] == '5') {
if (isset($params['montantfrais']) && (int)$params['montantfrais'] > 0 && $validator->isValid($params['montantfrais'])) {
$isExistFrais = $promoCommand->fetchRow("MONTANTVALID IS NOT NULL");
if ($isExistFrais) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTVALID' => $filter->filter($params['montantfrais'])
);
$promoCommand->update($data,'ID = '.$isExistFrais['ID']);
$this->view->messageSuccess = "La validit� de la commande a �t� modifi�e ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTVALID' => $filter->filter($params['montantfrais'])
);
$promoCommand->insert($data);
$this->view->messageSuccess = "La validit� de la commande a �t� modifi�e ";
}
} else {
$this->view->messageError = "Le montant de la commande doit etre sup�rieur � 0";
}
}
if (isset($params['remisepour']) && isset($params['remiseeuro'])) {
$remiseeuro = !empty($params['remiseeuro']) ? $params['remiseeuro'] : 0;
$remisepour = (int)$params['remisepour'];
$isOK = true;
if ($remiseeuro > 0 && $remisepour > 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($remiseeuro == 0 && $remisepour == 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE et est obligatoire. ";
$isOK = false;
}
if (($validator->isValid($remiseeuro) ||
$validator->isValid($remisepour)) && $isOK == true
) {
switch ($params['remise']) {
case 4 :
if (isset($params['montantfrais']) && (int)$params['montantfrais'] > 0) {
$isExistFrais = $promoCommand->fetchRow("MONTANTFRAISCMD IS NOT NULL AND MONTANTFRAISCMD = ".$params['montantfrais']);
if ($isExistFrais) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTFRAISCMD' => $filter->filter($params['montantfrais']),
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour
);
$promoCommand->update($data,'ID = '.$isExistFrais['ID']);
$this->view->messageSuccess = "Les frais de livraison sont modifi�s ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTFRAISCMD' => $filter->filter($params['montantfrais']),
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour
);
$promoCommand->insert($data);
$this->view->messageSuccess = "Les frais de livraison sont modifi�s ";
}
} else {
$this->view->messageError = "Le montant de la commande doit etre sup�rieur � 0";
}
break;
default:
$this->_forward('command');
break;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "V�rifier les param�tres";
}
$this->_forward('list');
}
function commanddelAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$promoCommand = new PromoCommand();
$promoCommand->delete('ID = '.$id);
$this->view->messageSuccess = "La configuration � �t� supprim�e ";
} else {
$this->view->messageError = "La configuration n'a pas �t� supprim�e ";
}
}
$this->_forward('list');
}
}
?>PK �0H[`�� � AnnoncecontentController.phpnu &1i� <?php
class Backoffice_AnnoncecontentController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "AnnonceContent";
$this->isConnectedWithRole('isPromo');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$annonce = new AnnonceContent();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow']
);
if ($validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� modifi�e";
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
$this->log("L'annonce a �t� modifi�e : ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonce = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function addAction()
{
$this->view->titlePage = "Ajouter une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'TITRE' => $filter->filter($params['titre']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow']
);
if (
$validator->isValid($dataAnnonce['TITRE']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$annonce = new AnnonceContent();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "L'annonce a �t� ajout�e";
$this->log("L'annonce a �t� ajout�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonce = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function listAction()
{
$this->view->titlePage = "Gestion des publicit�s sur la page d'accueil";
$adminNamespace = $this->getSession();
//Appel model pour listing
$annonces = new AnnonceContent();
$result = $annonces->select()->order('isSHOW ASC')->order('TITRE ASC')->query()->fetchAll();
$this->view->listannonce = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceContent();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� supprim�e";
$this->log("L'annonce a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[�|{� � AdminController.phpnu &1i� <?php
class Backoffice_AdminController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Admin";
$this->isConnectedWithRole('isAdmin');
}
function indexAction()
{
$this->_forward('/list');
}
function setroleAction()
{
if ($this->_request->isPost()) {
$params = $this->_request->getPost();
if ($params['roletype'] == 'isPromo') { $data = array('isPROMO' => $params['rolevalue']); }
if ($params['roletype'] == 'isCategory') { $data = array('isCATEGORY' => $params['rolevalue']); }
if ($params['roletype'] == 'isCommand') { $data = array('isCOMMAND' => $params['rolevalue']); }
if ($params['roletype'] == 'isProduct') { $data = array('isPRODUCT' => $params['rolevalue']); }
if ($params['roletype'] == 'isSupplier') { $data = array('isSUPPLIER' => $params['rolevalue']); }
if ($params['roletype'] == 'isUser') { $data = array('isUSER' => $params['rolevalue']); }
if ($params['roletype'] == 'isAdmin') { $data = array('isADMIN' => $params['rolevalue']); }
if ($params['roletype'] == 'isFooter') { $data = array('isFOOTER' => $params['rolevalue']); }
if ($params['roletype'] == 'isStats') { $data = array('isSTATS' => $params['rolevalue']); }
$id = $params['idadmin'];
try {
if ( $id > 0) {
$admin = new Admin();
$admin->update($data, 'ID = '.$id);
}
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
$this->_forward('/list');
}
}
$this->_forward('/list');
}
function listAction()
{
$this->view->titlePage = "Gestion des administrateurs";
$adminNamespace = $this->getSession();
//Gestion des tris
$table = 'NOM';
$tri = 'ASC';
if ($this->_request->getParam('col'))
{
$adminNamespace->triAdminCol = $this->_request->getParam('col');
($adminNamespace->triAdminSens == 'ASC') ? $adminNamespace->triAdminSens = 'DESC' : $adminNamespace->triAdminSens = 'ASC';
}
if (isset($adminNamespace->triAdminCol)) {
$table = $adminNamespace->triAdminCol;
$tri = $adminNamespace->triAdminSens;
}
//Appel model pour listing
$admin = new Admin();
$select = $admin->select()->where("Login <> 'Maintenance'")->order($table.' '.$tri);
$this->view->listadmins = $admin->fetchAll($select);
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$admin = new Admin();
$admin->delete('ID = '.$id);
$this->view->messageSuccess = "L'administrateur � �t� supprim�";
$this->log("L'administrateur a ete supprime",'info');
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
function editAction()
{
$this->view->titlePage = "Modifer un administrateur";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$validatorEmail = new Zend_Validate_EmailAddress();
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataTemp = array (
'NOM' => $filter->filter($params['lastname']),
'ID' => $filter->filter($params['id']),
'PRENOM' => $filter->filter($params['firstname']),
'LOGIN' => $filter->filter($params['login']),
'EMAIL' => $filter->filter($params['email'])
);
$mdp = $filter->filter($params['editpassword']);
$mdp2 = $filter->filter($params['editpassword2']);
if ($validator->isValid($dataTemp['NOM']) &&
$validator->isValid($dataTemp['PRENOM']) &&
$validator->isValid($dataTemp['LOGIN']) &&
$validatorEmail->isValid($dataTemp['EMAIL'])
) {
$data = array (
'NOM' => $dataTemp['NOM'],
'PRENOM' => $dataTemp['PRENOM'],
'LOGIN' => $dataTemp['LOGIN'],
'EMAIL' => $dataTemp['EMAIL']
);
if ($validator->isValid($mdp) && $validator->isValid($mdp2) &&
($mdp == $mdp2)) {
$data['MDP'] = md5($mdp);
}
try {
$id = $dataTemp['ID'];
if ( $id > 0) {
$admin = new Admin();
$n = $admin->update($data, 'ID = '.$id);
$this->log('Update : '.$n.' : '.$data['NOM'].' '.$data['PRENOM'],'info');
$this->_forward('/list');
}
} catch (Zend_Exception $e) {
$this->view->messageError = "L'email ou le login existe d�j�";
$this->log($e->getMessage(),'err');
$this->view->populateForm = $dataTemp;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
foreach ($validatorEmail->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateForm = $dataTemp;
}
} else {
//populate form
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
$admin = new Admin();
$row = $admin->fetchRow('ID = '.$id);
$this->view->populateForm = $row->toArray();
}
}
}
function addAction()
{
$this->view->titlePage = "Ajouter un administrateur";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$validatorEmail = new Zend_Validate_EmailAddress();
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$mdp = $filter->filter($params['addpassword']);
$mdp2 = $filter->filter($params['addpassword2']);
$dataTemp = array (
'NOM' => $filter->filter($params['lastname']),
'PRENOM' => $filter->filter($params['firstname']),
'LOGIN' => $filter->filter($params['addlogin']),
'EMAIL' => $filter->filter($params['email'])
);
if ($validator->isValid($dataTemp['NOM']) &&
$validator->isValid($dataTemp['PRENOM']) &&
$validator->isValid($dataTemp['LOGIN']) &&
$validatorEmail->isValid($dataTemp['EMAIL']) &&
$validator->isValid($mdp) &&
$validator->isValid($mdp2) &&
($mdp == $mdp2)
) {
$data = array (
'NOM' => $dataTemp['NOM'],
'PRENOM' => $dataTemp['PRENOM'],
'LOGIN' => $dataTemp['LOGIN'],
'MDP' => md5($mdp),
'EMAIL' => $dataTemp['EMAIL'],
'ROLE' => '100'
);
try {
$admin = new Admin();
$admin->insert($data);
$this->view->messageSuccess = "L'administrateur a �t� ajout�";
$this->log("L'administrateur a �t� ajout�",'info');
} catch (Zend_Exception $e) {
$this->view->messageError = "L'email ou le login existe d�j�";
$this->log($e->getMessage(),'err');
$this->view->populateForm = $dataTemp;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
foreach ($validatorEmail->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateForm = $dataTemp;
}
}
}
}
?>PK �0H[��H
H
ToolController.phpnu &1i� <?php
class Backoffice_ToolController extends Modules_Backoffice_Controllers_MainController
{
function init() { }
function redactorlistpicturesAction() {
$repertoireDestination = "/items/datas/images/";
$array = array();
try {
$scanned_directory = array_diff(scandir($_SERVER['DOCUMENT_ROOT'].$repertoireDestination), array('..', '.'));
foreach ($scanned_directory as $image) {
$path = $repertoireDestination.$image;
array_push($array, array("thumb" => $path, "image" => $path, "title" => $image));
}
} catch (Exception $e) {
$array = array( 'error' => $e->getMessage());
$this->log($e->getMessage(),'err');
}
echo Zend_Json::encode($array);
exit();
}
function redactoruploadpicturesAction() {
$repertoireDestination = "/items/datas/images/";
$array = array();
try {
if(!empty($_FILES['file']) && !empty($_FILES['file']['name'])) {
$nomOrigine = $_FILES['file']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpeg", "jpg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$array = array( 'error' => "Extension attendue : jpeg, jpg, gif, png");
} else {
if (move_uploaded_file($_FILES["file"]["tmp_name"],$_SERVER['DOCUMENT_ROOT'].$repertoireDestination.$nomOrigine)) {
$array = array(
'filelink' => $repertoireDestination.$nomOrigine,
'filename' => $nomOrigine
);
} else {
$array = array( 'error' => "Impossible d'enregistrer l'image");
}
}
}
} catch (Exception $e) {
$array = array( 'error' => $e->getMessage());
$this->log($e->getMessage(),'err');
}
echo Zend_Json::encode($array);
exit();
}
function redactorlistfilesAction() {
$repertoireDestination = "/items/datas/fichiers/";
$array = array();
try {
$scanned_directory = array_diff(scandir($_SERVER['DOCUMENT_ROOT'].$repertoireDestination), array('..', '.'));
foreach ($scanned_directory as $image) {
$path = $repertoireDestination.$image;
array_push($array, array("thumb" => $path, "image" => $path, "title" => $image));
}
} catch (Exception $e) {
$array = array( 'error' => $e->getMessage());
$this->log($e->getMessage(),'err');
}
echo Zend_Json::encode($array);
exit();
}
function redactoruploadfilesAction() {
$repertoireDestination = "/items/datas/fichiers/";
$array = array();
try {
if(!empty($_FILES['file']) && !empty($_FILES['file']['name'])) {
$nomOrigine = $_FILES['file']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("pdf");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$array = array( 'error' => "Extension attendue : pdf");
} else {
if (move_uploaded_file($_FILES["file"]["tmp_name"],$_SERVER['DOCUMENT_ROOT'].$repertoireDestination.$nomOrigine)) {
$array = array(
'filelink' => $repertoireDestination.$nomOrigine,
'filename' => $nomOrigine
);
} else {
$array = array( 'error' => "Impossible d'enregistrer le fichier");
}
}
}
} catch (Exception $e) {
$array = array( 'error' => $e->getMessage());
$this->log($e->getMessage(),'err');
}
echo Zend_Json::encode($array);
exit();
}
}
?>PK �0H[�� � BlogCategoryController.phpnu &1i� <?php
class Backoffice_BlogCategoryController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "BlogCategory";
}
function indexAction()
{
$this->_forward('/list');
}
function listAction()
{
try {
$this->view->titlePage = "Gestion des cat�gories du blog";
$blogCategory = new BlogCategory();
$this->view->listallblogcategories = $blogCategory->AllCategories(0);
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$category = new BlogCategory();
if ($category->fetchRow('id_parent = '.$id)) {
$this->view->messageError = 'Cette cat�gorie est parente';
} else {
$subject = new BlogSubject();
$select = $subject->fetchRow('id_category = '.$id);
if ($select) {
$this->view->messageError = 'Cette cat�gorie est utilis�e par le sujet : <b>'.$select->title."<b/>";
} else {
$category->delete('id = '.$id);
$this->view->messageSuccess = "La cat�gorie du blog a et� supprim�e";
$this->log("La cat�gorie du blog a et� supprim�e",'info');
}
}
}
catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
public function addAction()
{
$data = array (
'is_publish' => 0,
'is_close' => 0,
'title' => "",
'sub_title' => "",
'message' => ""
);
try {
$blogCategory = new BlogCategory();
$this->view->listallblogcategories = $blogCategory->AllCategories(0);
$this->view->titlePage = "Ajouter une cat�gorie";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'is_publish' => (int)$params['is_publish'],
'title' => $filter->filter($params['title']),
'message' => $params['message'],
'sub_title' => $params['sub_title'],
'is_close' => (int)$params['is_close'],
'date_updated' => date('Y-m-d H:i:s') ,
'id_parent' => (int)$params['idparent']
);
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
if (
$validator->isValid($data['title']) &&
$data['id_parent'] > 0
) {
$blogCategory->insert($data);
$this->view->messageSuccess = "La cat�gorie a �t� ajout�e";
$data['title'] = "";
$data['sub_title'] = "";
$data['message'] = "";
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
if ($data['id_parent'] == 0) {
$this->view->messageError .= "Choisissez une cat�gorie parente.";
}
}
}
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
$this->view->populateData = $data;
}
public function editAction()
{
$data = array (
'is_publish' => 0,
'is_close' => 0,
'title' => "",
'sub_title' => "",
'message' => ""
);
try {
$blogCategory = new BlogCategory();
$this->view->listallblogcategories = $blogCategory->AllCategories(0);
$this->view->titlePage = "Modifier une cat�gorie";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateData = $blogCategory->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'id' => (int)$params['id'],
'is_publish' => (int)$params['is_publish'],
'title' => $filter->filter($params['title']),
'message' => $params['message'],
'sub_title' => $params['sub_title'],
'is_close' => (int)$params['is_close'],
'date_updated' => date('Y-m-d H:i:s') ,
'id_parent' => (int)$params['idparent']
);
$this->view->populateData = $data;
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
if (
$validator->isValid($data['title'])
) {
$id = (int)$params['id'];
if ( $id > 0) {
$blogCategory->update($data,'ID = '.$id);
$this->view->messageSuccess = "La cat�gorie a �t� modifi�e";
$this->view->populateData = $blogCategory->fetchRow('ID = '.$id);
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
if ($data['id_parent'] == 0) {
$this->view->messageError .= "Choisissez une cat�gorie parente.";
}
}
}
}
catch (Zend_Exception $e) {
$this->view->populateData = $data;
$this->log($e->getMessage(),'err');
}
}
}
?>PK �0H[�w�= = BlogSubjectController.phpnu &1i� <?php
class Backoffice_BlogSubjectController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "BlogSubject";
}
function indexAction()
{
$this->_forward('/search');
}
public function searchAction()
{
$this->view->titlePage = "Rechercher un sujet";
$data = array (
'title' => "",
'is_publish' => 0,
'is_close' => 0,
'id_category' => 0
);
$blogCategory = new BlogCategory();
$this->view->listallblogcategories = $blogCategory->AllCategories(0);
$this->view->listallsubjects = array();
try {
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'title' => $filter->filter($params['title']),
'is_publish' => (int)$params['is_publish'],
'is_close' => (int)$params['is_close'],
'id_category' => (int)$params['id_category']
);
$blogSubject = new BlogSubject();
$this->view->listallsubjects = $blogSubject->getPostBySearch($data);
}
$this->view->populateData = $data;
} catch (Zend_Exception $e) {
$this->view->populateData = $data;
$this->log($e->getMessage(),'err');
}
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$subject = new BlogSubject();
$subject->delete('id = '.$id);
$this->view->messageSuccess = "Le sujet a et� supprim�";
$this->log("Le sujet a et� supprim�",'info');
}
catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
public function addAction()
{
$data = array (
'is_publish' => 0,
'is_close' => 0,
'title' => "",
'sub_title' => "",
'message' => "",
'id_category' => 0
);
try {
$blogCategory = new BlogCategory();
$this->view->listallblogcategories = $blogCategory->AllCategories(0);
$this->view->titlePage = "Ajouter un sujet";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'is_publish' => (int)$params['is_publish'],
'title' => $filter->filter($params['title']),
'message' => $params['message'],
'sub_title' => $params['sub_title'],
'is_close' => (int)$params['is_close'],
'date_updated' => date('Y-m-d H:i:s') ,
'id_category' => (int)$params['id_category']
);
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
if (
$validator->isValid($data['title']) &&
$data['id_category'] > 0
) {
$blogSubject = new BlogSubject();
$blogSubject->insert($data);
$this->view->messageSuccess = "Le sujet a �t� ajout�";
$data['title'] = "";
$data['sub_title'] = "";
$data['message'] = "";
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
if ($data['id_category'] == 0) {
$this->view->messageError .= "Choisissez une cat�gorie.";
}
}
}
}
catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
$this->view->populateData = $data;
}
public function editAction()
{
$data = array (
'is_publish' => 0,
'is_close' => 0,
'title' => "",
'sub_title' => "",
'message' => "",
'id_category' => 0
);
try {
$blogCategory = new BlogCategory();
$blogSubject = new BlogSubject();
$this->view->listallblogcategories = $blogCategory->AllCategories(0);
$this->view->titlePage = "Modifier un sujet";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateData = $blogSubject->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'id' => (int)$params['id'],
'is_publish' => (int)$params['is_publish'],
'title' => $filter->filter($params['title']),
'message' => $params['message'],
'sub_title' => $params['sub_title'],
'is_close' => (int)$params['is_close'],
'date_updated' => date('Y-m-d H:i:s') ,
'id_category' => (int)$params['id_category']
);
$this->view->populateData = $data;
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
if ( $validator->isValid($data['title']) ) {
$id = (int)$params['id'];
if ( $id > 0) {
$blogSubject->update($data,'ID = '.$id);
$this->view->messageSuccess = "Le sujet a �t� modifi�.";
$this->view->populateData = $blogSubject->fetchRow('ID = '.$id);
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
if ($data['id_category'] == 0) {
$this->view->messageError .= "Choisissez une cat�gorie.";
}
}
}
}
catch (Zend_Exception $e) {
$this->view->populateData = $data;
$this->log($e->getMessage(),'err');
}
}
}
?>PK �0H[��_�� � AnnoncecmsController.phpnu &1i� <?php
class Backoffice_AnnoncecmsController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "AnnonceCms";
$this->isConnectedWithRole('isCategory');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier un article";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$annonce = new AnnonceCms();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonceCms = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'CONTENT_SHORT' => $filter->filter($params['content_short']),
'CONTENT_LONG' => $params['content_long'],
'POSITION' => (int) $filter->filter($params['position']),
'isSHOW' => $params['isshow'],
'ID_CATS' => ''
);
if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}
if ($validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT'])&&
!empty($dataAnnonce['ID_CATS'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'article a �t� modifi�";
$this->view->populateFormAnnonceCms = $annonce->fetchRow('ID = '.$id);
$this->log("L'article a �t� modifi� ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceCms = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceCms = $dataAnnonce;
}
}
}
public function addAction()
{
$this->view->titlePage = "Ajouter un article";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'CONTENT_SHORT' => $filter->filter($params['content_short']),
'CONTENT_LONG' => $params['content_long'],
'POSITION' => (int) $filter->filter($params['position']),
'isSHOW' => $params['isshow'],
'ID_CATS' => ''
);
if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}
if (
$validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT']) &&
!empty($dataAnnonce['ID_CATS'])
) {
try {
$annonce = new AnnonceCms();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "L'article a �t� ajout�";
$this->log("L'article a �t� ajout�",'info');
$lastid = $annonce->getAdapter()->lastInsertId();
$this->_request->setParam('id', $lastid);
$this->_forward('/edit');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceCms = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceCms = $dataAnnonce;
}
}
}
public function listAction()
{
$this->view->titlePage = "Gestion des articles";
//Appel model pour listing
$annonces = new AnnonceCms();
$result = $annonces->getAllAnnonces();
$category = new Category();
$this->view->listallcategories = $category->getAllCategoriesByID(0);
$this->view->listAnnoncecms = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceCms();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "L'article a �t� supprim�";
$this->log("L'article a �t� supprim�",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[�?� � ProductoptionlistController.phpnu &1i� <?php
class Backoffice_ProductoptionlistController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->isConnectedWithRole('isProduct');
}
public function indexAction()
{
$this->_forward('/option');
}
public function optionAction() {
$this->view->titlePage = "Gestion des caract�ristiques s�lectionnable";
$this->view->currentMenu = "Option";
$optionList = new OptionList();
if ($this->_request->isPost() && (int)$this->_request->getParam('id') ==0) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$values = explode(",", $params['value']);
$result = "";
foreach ($values as $value) {
$valTemp = $filter->filter($value);
if (!empty($valTemp)) {
if (empty($result)) {
$result .= $filter->filter($valTemp);
} else {
$result .= "::".$filter->filter($valTemp);
}
}
}
$data = array (
'NAME' => $filter->filter($params['name']),
'VALUE' => $result
);
if ($validator->isValid($data['NAME']) && $validator->isValid($data['VALUE'])) {
try {
$optionList->insert($data);
$this->view->messageSuccess = "La caract�ristique a �t� ajout�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La caract�ristique existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->view->listoption = $optionList->getAll();
}
public function optioneditAction()
{
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$values = explode(",", $params['value']);
$result = "";
foreach ($values as $value) {
$valTemp = $filter->filter($value);
if (!empty($valTemp)) {
if (empty($result)) {
$result .= $filter->filter($valTemp);
} else {
$result .= "::".$filter->filter($valTemp);
}
}
}
$data = array (
'NAME' => $filter->filter($params['name']),
'VALUE' => $result,
'ID' => $filter->filter($params['id'])
);
if ($validator->isValid($data['NAME']) && $validator->isValid($data['VALUE']) ) {
try {
$optionList = new OptionList();
$optionList->update($data, 'ID = '.$data['ID']);
$this->view->messageSuccess = "La caract�ristique a �t� modifi�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La caract�ristique existe d�ja";
$this->_forward('option');
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('option');
}
public function optiondelAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$optionList = new OptionList();
$isExistProduct = $optionList->getProductByIdOption($id);
if (!$isExistProduct) {
$optionList->delete('ID = '.$id);
$this->view->messageSuccess = "La caract�ristique a �t� supprim�e";
} else {
$this->view->messageError = "La caract�ristique est utilis�e par : <b/>".$isExistProduct['NOM']."</b>";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
$this->_forward('/option');
}
}
}
$this->_forward('/option');
}
}
?>PK �0H[�r�Ҋ Ҋ CsvController.phpnu &1i� <?php
class Backoffice_CsvController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Export";
$this->isConnectedWithRole('isStats');
}
function indexAction()
{
$this->_forward('/export');
}
function exporthelloAction() {
try {
$this->_helper->viewRenderer->setNeverRender();
$this->view->titlePage = "Exporter le fichier CSV";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel();
$fichier->Colonne("Nom du produit;Description du produit;Lien image du produit;Url vers la fiche produit sur le site du client;Lien vers une documentation sur le produit au format pdf;Identifiant unique du produit;Mot cl� 1;Mot cl� 2;Mot cl� 3;Mot cl� 4;Mot cl� 5;Mot cl� 6;Mot cl� 7;Mot cl� 8;Mot cl� 9;Mot cl� 10;Prix HT en �;Domaine d'utilisation;Marque du produit;Frais de port;Delai de livraison;Garantie;Disponibilit�;Quantit� minimum;EAN");
$sql = "SELECT p.ID ID, p.NOM NOM, p.NAVNOM NAVNOM, p.DESCRIPTIONSHORT DESCSHORT, p.DESCRIPTIONLONG DESCLONG, p.PRIX PRIX, p.isDEVIS isDEVISPRODUCT,
p.DOCNAME DOCNAME, p.DOCURL DOCURL, p.IDBREND IDBREND,
p.isPROMO isPROMO, pic.URL URLIMAGE, sb.BREND BREND, sb.URL BRENDURL, p.IDCATEGORY IDCATEGORY, c.NOM CATEGORYNOM, c.NAVNOM CATEGORYNAV,
p.DESCRIPTIONTECH DESCTECH, p.DESCRIPTIONNORME DESCNORME, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS
FROM product p
LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID
LEFT JOIN supplier_brend sb ON sb.ID = p.IDBREND
LEFT JOIN category AS c ON c.ID = p.IDCATEGORY
WHERE p.isACTIVE = 0
AND pic.POSITION = 1
GROUP BY ID
ORDER BY p.ID ASC";
$product = new Product();
$productChild = new ProductChild();
$listProducts = $product->getAdapter()->fetchAll($sql);
foreach ($listProducts as $row) {
$sqlChild = "
SELECT pc.ID ID ,pc.REFERENCE REFERENCE,pc.DESIGNATION DESIGNATION,pc.PRIX PRIX, pc.isPROMO isPROMO ,
pc.IMAGEPROMO IMAGEPROMO,pc.isDEVIS isDEVIS, pc.QUANTITYMIN QUANTITYMIN
FROM productchild AS pc
WHERE pc.IDPRODUCT = ".$row['ID']."
ORDER BY pc.PRIX ASC";
$productChildTemp = $productChild->getAdapter()->fetchAll($sqlChild);
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$row['URLIMAGE'];
//$urlPage = $this->baseUrl_SiteCommerceUrl."/produits/detail/page/".$navnom."/p/".$row['ID'];
$urlPage = $this->getUrlPage(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'], 'PAGE' => $navnom, 'ID' => $row['ID']));
$motcle = array();
$navnomStrip = explode("-", $navnom);
for ($index = 0; $index < sizeof($navnomStrip); $index++) {
$word = $navnomStrip[$index];
if (strlen($word) > 3){
array_push($motcle, $word);
}
}
if (sizeof($motcle) < 10) {
$navnomcat = explode("-", $row['CATEGORYNAV']);
for ($index = 0; $index < sizeof($navnomcat); $index++) {
$word = $navnomcat[$index];
if (strlen($word) > 3){
array_push($motcle, $word);
}
}
if (sizeof($motcle) < 10) {
$brend = $row['BREND'];
array_push($motcle, $brend);
}
if (sizeof($motcle) < 10) {
for ($index = sizeof($motcle); $index < 10; $index++) {
array_push($motcle, $this->siteName);
}
}
}
$reference = "";
$prix = "";
$description = "";
foreach ($productChildTemp as $rowChild) {
$reference = $rowChild['REFERENCE'];
$prix = $rowChild['PRIX'];
$descTemp = $row['DESCSHORT']." ".$rowChild['DESIGNATION'];
$description = $this->cleanUp($descTemp);
$description = addslashes($description);
break;
}
$fichier->Insertion('"'.$row['NOM'].'";"'.$description.'";"'.$urlImage.'";"'.$urlPage.'";"'.$row['DOCURL'].'";"'.$reference.'";"'.$motcle[0].'";"'.$motcle[1].'";"'.$motcle[2].'";"'.$motcle[3].'";"'.$motcle[4].'";"'.$motcle[5].'";"'.$motcle[6].'";"'.$motcle[7].'";"'.$motcle[8].'";"'.$motcle[9].'";'.$prix.';;"'.$row['BREND'].'";;"48H par TNT";;0;;');
}
$fichier->output('hellopro_fr');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
function exportleguideAction() {
try {
$this->_helper->viewRenderer->setNeverRender();
$this->view->titlePage = "Exporter le fichier CSV";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel();
$fichier->Colonne("categorie;identifiant_unique;titre;description;prix;url_produit;url_image;frais_de_livraison;disponibilite;delais_de_livraison;garantie;reference_modele;D3E;marque;ean;prix_barre;type_promotion;devise;occasion;URL_mobile");
$sql = "SELECT p.ID ID, p.NOM NOM,p.NAVNOM NAVNOM, p.DESCRIPTIONSHORT DESCSHORT, p.DESCRIPTIONLONG DESCLONG, p.PRIX PRIX, p.isDEVIS isDEVISPRODUCT,
p.DOCNAME DOCNAME, p.DOCURL DOCURL, p.IDBREND IDBREND,
p.isPROMO isPROMO, pic.URL URLIMAGE, sb.BREND BREND, sb.URL BRENDURL, p.IDCATEGORY IDCATEGORY, c.NOM CATEGORYNOM,
p.DESCRIPTIONTECH DESCTECH, p.DESCRIPTIONNORME DESCNORME, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS
FROM product p
LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID
LEFT JOIN supplier_brend sb ON sb.ID = p.IDBREND
LEFT JOIN category AS c ON c.ID = p.IDCATEGORY
WHERE p.isACTIVE = 0
AND pic.POSITION = 1
GROUP BY ID
ORDER BY p.ID ASC";
$product = new Product();
$productChild = new ProductChild();
$listProducts = $product->getAdapter()->fetchAll($sql);
foreach ($listProducts as $row) {
$sqlChild = "
SELECT pc.ID ID ,pc.REFERENCE REFERENCE,pc.DESIGNATION DESIGNATION,pc.PRIX PRIX, pc.isPROMO isPROMO ,
pc.IMAGEPROMO IMAGEPROMO,pc.isDEVIS isDEVIS, pc.QUANTITYMIN QUANTITYMIN
FROM productchild AS pc
WHERE pc.IDPRODUCT = ".$row['ID']."
ORDER BY pc.PRIX ASC";
$productChildTemp = $productChild->getAdapter()->fetchAll($sqlChild);
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$row['URLIMAGE'];
//$urlPage = $this->baseUrl_SiteCommerceUrl."/produits/detail/".$navnom."/p/".$row['ID'];
$urlPage = $this->getUrlPage(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'],'PAGE' => $navnom, 'ID' => $row['ID']));
$fraislivraison = "";
$garantie="";
$reference = "";
$prix = "";
$description = "";
foreach ($productChildTemp as $rowChild) {
$reference = $rowChild['REFERENCE'];
$prix = $rowChild['PRIX'];
$descTemp = $row['DESCSHORT']." ".$rowChild['DESIGNATION'];
$description = $this->cleanUp($descTemp);
$description = addslashes($description);
break;
}
$fichier->Insertion('"'.$row['CATEGORYNOM'].'";"'.$reference.'";"'.$row['NOM'].'";"'.$description.'";"'.$prix.'";"'.$urlPage.'";"'.$urlImage.'";"'.$fraislivraison.'";"0";"48 heures";"'.$garantie.'";;;;;;;;;');
}
$fichier->output('leguide_fr');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
function exportkelkooAction() {
try {
$this->_helper->viewRenderer->setNeverRender();
$this->view->titlePage = "Exporter le fichier CSV";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierText();
$fichier->Colonne("id|model|brand|description|price|url|merchantcat|image|ean|sku|used|availability|deliveryprice|deliveryTime|deliveryinfo|warranty|ecotax|catkkid|taggingmatching|voucher|voucherdesc|voucherurl|vouchercode|voucherstart|voucherend|pricenorebate|percentagepromo|promostart|promoend|offertype|flag|shopinfo|validity");
$sql = "SELECT p.ID ID, p.NOM NOM,p.NAVNOM NAVNOM, p.DESCRIPTIONSHORT DESCSHORT, p.DESCRIPTIONLONG DESCLONG, p.PRIX PRIX, p.isDEVIS isDEVISPRODUCT,
p.DOCNAME DOCNAME, p.DOCURL DOCURL, p.IDBREND IDBREND,
p.isPROMO isPROMO, pic.URL URLIMAGE, sb.BREND BREND, sb.URL BRENDURL, p.IDCATEGORY IDCATEGORY, c.NOM CATEGORYNOM, c.NAVNOM CATEGORYNAV, c.DESCRIPTION CATEGORYDESC,
p.DESCRIPTIONTECH DESCTECH, p.DESCRIPTIONNORME DESCNORME, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS
FROM product p
LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID
LEFT JOIN supplier_brend sb ON sb.ID = p.IDBREND
LEFT JOIN category AS c ON c.ID = p.IDCATEGORY
WHERE p.isACTIVE = 0
AND pic.POSITION = 1
GROUP BY ID
ORDER BY p.ID ASC";
$product = new Product();
$productChild = new ProductChild();
$listProducts = $product->getAdapter()->fetchAll($sql);
foreach ($listProducts as $row) {
$sqlChild = "
SELECT pc.ID ID ,pc.REFERENCE REFERENCE,pc.DESIGNATION DESIGNATION,pc.PRIX PRIX, pc.isPROMO isPROMO ,
pc.IMAGEPROMO IMAGEPROMO,pc.isDEVIS isDEVIS, pc.QUANTITYMIN QUANTITYMIN
FROM productchild AS pc
WHERE pc.IDPRODUCT = ".$row['ID']."
ORDER BY pc.PRIX ASC";
$productChildTemp = $productChild->getAdapter()->fetchAll($sqlChild);
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$row['URLIMAGE'];
//$urlPage = $this->baseUrl_SiteCommerceUrl."/produits/detail/page/".$navnom."/p/".$row['ID'];
$urlPage = $this->getUrlPage(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'],'PAGE' => $navnom, 'ID' => $row['ID']));
$motcle = array();
$navnomStrip = explode("-", $navnom);
for ($index = 0; $index < sizeof($navnomStrip); $index++) {
$word = $navnomStrip[$index];
if (strlen($word) > 3){
array_push($motcle, $word);
}
}
if (sizeof($motcle) < 10) {
$navnomcat = explode("-", $row['CATEGORYNAV']);
for ($index = 0; $index < sizeof($navnomcat); $index++) {
$word = $navnomcat[$index];
if (strlen($word) > 3){
array_push($motcle, $word);
}
}
if (sizeof($motcle) < 10) {
$brend = $row['BREND'];
array_push($motcle, $brend);
}
if (sizeof($motcle) < 10) {
for ($index = sizeof($motcle); $index < 10; $index++) {
array_push($motcle, $this->siteName);
}
}
}
$reference = "";
$prix = "";
$description = "";
foreach ($productChildTemp as $rowChild) {
$reference = $rowChild['REFERENCE'];
$prix = $rowChild['PRIX'];
$descTemp = $row['DESCSHORT']." ".$rowChild['DESIGNATION'];
$description = $this->cleanUp($descTemp);
$description = str_replace("|", "", $description);
$description = addslashes($description);
break;
}
$catkid = "";
$shopinfo = $this->siteName." : ".str_replace("|", "", $this->cleanUp($row['CATEGORYDESC']));
$validity = "";
$fichier->Insertion('"'.$reference.'"|"'.$row['NOM'].'"|"'.$row['BREND'].'"|"'.$description.'"|'.$prix.'|"'.$urlPage.'"|"'.$row['CATEGORYNOM'].'"|"'.$urlImage.'"||||1||"Sous 48 heures"|"Livraison TNT Express"|||'.$catkid.'|"'.$motcle[0].' '.$motcle[1].' '.$motcle[2].' '.$motcle[3].' '.$motcle[4].'"|||||||||||single||"'.$shopinfo.'"|"'.$validity.'"');
}
$fichier->output('kelkoo_fr');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
function exportciaoAction() {
try {
$this->_helper->viewRenderer->setNeverRender();
$this->view->titlePage = "Exporter le fichier CSV";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel();
$fichier->Colonne("Name;Brand;MNP;Deeplink;Imagelink;Price;ShippingCost;Delivery;Merchant;Category;SKU;offerID;Description");
$sql = "SELECT p.ID ID, p.NOM NOM,p.NAVNOM NAVNOM, p.DESCRIPTIONSHORT DESCSHORT, p.DESCRIPTIONLONG DESCLONG, p.PRIX PRIX, p.isDEVIS isDEVISPRODUCT,
p.DOCNAME DOCNAME, p.DOCURL DOCURL, p.IDBREND IDBREND,
p.isPROMO isPROMO, pic.URL URLIMAGE, sb.BREND BREND, sb.URL BRENDURL, p.IDCATEGORY IDCATEGORY, c.NOM CATEGORYNOM, c.NAVNOM CATEGORYNAV,
p.DESCRIPTIONTECH DESCTECH, p.DESCRIPTIONNORME DESCNORME, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS
FROM product p
LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID
LEFT JOIN supplier_brend sb ON sb.ID = p.IDBREND
LEFT JOIN category AS c ON c.ID = p.IDCATEGORY
WHERE p.isACTIVE = 0
AND pic.POSITION = 1
GROUP BY ID
ORDER BY p.ID ASC";
$product = new Product();
$productChild = new ProductChild();
$listProducts = $product->getAdapter()->fetchAll($sql);
foreach ($listProducts as $row) {
$sqlChild = "
SELECT pc.ID ID ,pc.REFERENCE REFERENCE,pc.DESIGNATION DESIGNATION,pc.PRIX PRIX, pc.isPROMO isPROMO ,
pc.IMAGEPROMO IMAGEPROMO,pc.isDEVIS isDEVIS, pc.QUANTITYMIN QUANTITYMIN
FROM productchild AS pc
WHERE pc.IDPRODUCT = ".$row['ID']."
ORDER BY pc.PRIX ASC";
$productChildTemp = $productChild->getAdapter()->fetchAll($sqlChild);
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$row['URLIMAGE'];
//$urlPage = $this->baseUrl_SiteCommerceUrl."/produits/detail/page/".$navnom."/p/".$row['ID'];
$urlPage = $this->getUrlPage(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'],'PAGE' => $navnom, 'ID' => $row['ID']));
$reference = "";
$prix = "";
$description = "";
foreach ($productChildTemp as $rowChild) {
$reference = $rowChild['REFERENCE'];
$prix = $rowChild['PRIX'];
$descTemp = $row['DESCSHORT']." ".$rowChild['DESIGNATION'];
$description = $this->cleanUp($descTemp);
$description = addslashes($description);
break;
}
$fichier->Insertion('"'.$row['NOM'].'";"'.$row['BREND'].'";;"'.$urlPage.'";"'.$urlImage.'";'.$prix.';;"48h";;"'.$row['CATEGORYNOM'].'";"EUR";"'.$reference.'";"'.$description.'"');
}
$fichier->output('ciao_fr');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
public function sitemapxmlAction() {
try {
$this->view->titlePage = "Exporter le sitemap";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//get the form params
$params = $this->_request->getPost();
$changefreq = $params['changefreq'];
$priority = $params['priority'];
$isImageActive = $params['all_image'];
$isCheckLinkActive = $params['checklink'];
$isCustomNavnomActive = $params['all_navnom'];
// Instance de la class DomDocument
$doc = new DOMDocument();
// Definition de la version et l'encodage
$doc->version = '1.0';
$doc->encoding = 'UTF-8';
$isImage = true;
if ($isImageActive == "N") { $isImage = false; }
$body_elt = $doc->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
$doc->appendChild($body_elt);
if ($isImage) {
$body_elt->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:image', 'http://www.google.com/schemas/sitemap-image/1.1');
//$body_elt->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:video', 'http://www.google.com/schemas/sitemap-video/1.1');
}
$isDupliateByNavNom = false;
$isCheckLink = false;
if ($isCheckLinkActive == "Y") { $isCheckLink = true; }
$isCustomNavnom = false;
if ($isCustomNavnomActive == "Y") { $isCustomNavnom = true; }
$countDefault = $this->sitemapAddUrlDefault($doc, $body_elt, $isCheckLink);
$countProduct = $this->sitemapAddUrlProducts($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom,$isImage, $isCheckLink, $isCustomNavnom);
$countCategorie = $this->sitemapAddUrlCategories($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom,$isImage, $isCheckLink);
$countCategorie2 = $this->sitemapAddUrlCategories2($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom,$isImage, $isCheckLink);
$countServices = $this->sitemapAddUrlInfos($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom,$isImage, $isCheckLink);
$this->view->messageSuccess = "Le Sitemap a �t� remplac�.";
if ($countProduct['RESULT'] == 'SUCCESS') {
$this->view->messageSuccess .= " Produits : <b>".$countProduct['OK']."</b> urls,";
} else {
$this->view->messageError .= "Erreur sur les produits : ".$countProduct['OK']." urls OK, script interrompu. ".$countProduct['RESULT'];
}
if ($countCategorie['RESULT'] == 'SUCCESS') {
$this->view->messageSuccess .= " Cat�gories : <b>".$countCategorie['OK']."</b> urls,";
} else {
$this->view->messageError .= "Erreur sur les cat�gories : ".$countCategorie['OK']." urls OK, script interrompu. ".$countCategorie['RESULT'];
}
if ($countCategorie2['RESULT'] == 'SUCCESS') {
$this->view->messageSuccess .= " Cat�gories subsidiaires : <b>".$countCategorie2['OK']."</b> urls,";
} else {
$this->view->messageError .= "Erreur sur les cat�gories subsidiaires : ".$countCategorie2['OK']." urls OK, script interrompu. ".$countCategorie2['RESULT'];
}
if ($countServices['RESULT'] == 'SUCCESS') {
$this->view->messageSuccess .= " Informations : <b>".$countServices['OK']."</b> urls,";
} else {
$this->view->messageError .= "Erreur sur les informations : ".$countServices['OK']." urls OK, script interrompu. ".$countServices['RESULT'];
}
if ($countDefault['RESULT'] == 'SUCCESS') {
$this->view->messageSuccess .= " Connexions : <b>".$countDefault['OK']."</b> urls,";
} else {
$this->view->messageError .= "Erreur sur les connexions : ".$countDefault['OK']." urls OK, script interrompu. ".$countDefault['RESULT'];
}
$this->view->messageSuccess .= " Total de liens : <b>".($countProduct['OK']+$countCategorie['OK']+$countCategorie2['OK']+$countServices['OK']+$countDefault['OK'])."</b>";
if ($isCheckLink) {
$this->view->messageSuccess .= " V�rification des liens -> OK : <b>".($countProduct['OK']+$countCategorie['OK']+$countCategorie2['OK']+$countServices['OK']+$countDefault['OK'])."</b>";
$this->view->messageError .= " V�rification des liens -> Liens morts : <b>".($countProduct['NOK']+$countCategorie['NOK']+$countCategorie2['NOK']+$countServices['NOK']+$countDefault['NOK'])."</b>";
}
$doc->formatOutput = true;
// Sauver le document XML sous le nom simple.xml
$doc->save('sitemap.xml');
//echo $doc->saveXML();
if($this->pingBingForSitemap()) {
$this->view->messageSuccess .= ", Mise � niveau de Bing";
}
if($this->pingGoogleForSitemap()) {
$this->view->messageSuccess .= ", Mise � niveau de Google";
}
}
} catch (Zend_Exception $e) {
$this->log('Erreur lors de la generation du sitemap XML : '.$e->getMessage(),'err');
$this->view->messageError = "Erreur lors de la g�n�ration du sitemap XML : ".$e->getMessage();
}
}
private function pingBingForSitemap() {
return $this->sendUrlPostByRequest('http://www.bing.com/ping?sitemap='.$this->baseUrl_SiteCommerceUrl.'/sitemap.xml');
}
private function pingGoogleForSitemap() {
return $this->sendUrlPostByRequest('http://www.google.com/webmasters/sitemaps/ping?sitemap='.$this->baseUrl_SiteCommerceUrl.'/sitemap.xml');
}
private function sendUrlPostByRequest($url) {
$a = @get_headers($url);
if ($a) {
if (strstr($a[0],'200')) {
return true;
}
}
return false;
}
private function isLinkDead ($url) {
if ($this->sendUrlPostByRequest($url)) {
return false;
}
return true;
}
private function sitemapAddUrlProducts($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom, $isImage, $isCheckLink, $isCustomNavnom) {
try {
$countOk = 0;
$countNOk = 0;
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_CustomAccent())
->addFilter(new Zend_Filter_Alnum(array('allowwhitespace' => true)));
$filterLight = new Zend_Filter();
$filterLight->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
$sql = "SELECT p.ID ID, p.NOM NOM, p.NAVNOM NAVNOM, pic.URL URLIMAGE,
p.CUSTOM_NAVNOM1 CUSTOM_NAVNOM1 ,p.CUSTOM_NAVNOM2 CUSTOM_NAVNOM2 ,
p.CUSTOM_NAVNOM3 CUSTOM_NAVNOM3, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS
FROM product p
LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID
LEFT JOIN category c ON p.IDCATEGORY = c.ID
WHERE p.isACTIVE = 0
AND pic.POSITION = 1
GROUP BY ID
ORDER BY p.ID ASC";
$product = new Product();
$listProducts = $product->getAdapter()->fetchAll($sql);
$picture = new Picture();
$date = new Zend_Date();
$currentDate = $date->toString('YYYY-MM-dd');
$type = 1;
foreach ($listProducts as $row) {
$url_elt = $doc->createElement('url');
$body_elt->appendChild($url_elt);
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$urlPage = $this->getUrlPageProduct(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'],'PAGE' => $navnom, 'ID' => $row['ID'], 'TYPE' => $type));
$loc_elt = $doc->createElement('loc', $urlPage);
$url_elt->appendChild($loc_elt);
if ($isImage) {
$listPicture = $picture->fetchAll('IDPRODUCT = '.$row['ID']);
foreach ($listPicture as $pic) {
$image_elt = $doc->createElement('image:image');
$url_elt->appendChild($image_elt);
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$pic['URL'];
$imageloc_elt = $doc->createElement('image:loc',$urlImage);
$image_elt->appendChild($imageloc_elt);
$string1 = $filter->filter($pic['STRING1']);
if (isset($string1) && !empty($string1)) {
$imagetitle_elt = $doc->createElement('image:title', $string1);
$image_elt->appendChild($imagetitle_elt);
}
$string2 = $filter->filter($pic['STRING2']);
if (isset($string2) && !empty($string2)) {
$imagecaption_elt = $doc->createElement('image:caption', $string2);
$image_elt->appendChild($imagecaption_elt);
}
}
}
$lastmod_elt = $doc->createElement('lastmod', $currentDate);
$changefreq_elt = $doc->createElement('changefreq', $changefreq);
$priority_elt = $doc->createElement('priority', $priority);
$url_elt->appendChild($lastmod_elt);
$url_elt->appendChild($changefreq_elt);
$url_elt->appendChild($priority_elt);
if ($isCheckLink && $this->isLinkDead($urlPage)) { $countNOk++;
} else { $countOk++; }
if ($isCustomNavnom) {
for ($index = 1; $index < 4; $index++) {
$navnomTemp = $filterLight->filter($row['CUSTOM_NAVNOM'.$index]);
if (!empty($navnomTemp)) {
$url_elt = $doc->createElement('url');
$body_elt->appendChild($url_elt);
$navnom = $this->verifyNavigationString($navnomTemp, $navnomTemp, '');
$urlPage = $this->getUrlPageProduct(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'],'PAGE' => $navnom, 'ID' => $row['ID'], 'TYPE' => $type));
$loc_elt = $doc->createElement('loc', $urlPage);
$url_elt->appendChild($loc_elt);
if ($isImage) {
$listPicture = $picture->fetchAll('IDPRODUCT = '.$row['ID']);
//$urlPage = $this->baseUrl_SiteCommerceUrl."/produits/detail/page/".$navnom."/p/".$row['ID'];
foreach ($listPicture as $pic) {
$image_elt = $doc->createElement('image:image');
$url_elt->appendChild($image_elt);
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$pic['URL'];
$imageloc_elt = $doc->createElement('image:loc',$urlImage);
$image_elt->appendChild($imageloc_elt);
$string1 = $filter->filter($pic['STRING1']);
if (isset($string1) && !empty($string1)) {
$imagetitle_elt = $doc->createElement('image:title', $string1);
$image_elt->appendChild($imagetitle_elt);
}
$string2 = $filter->filter($pic['STRING2']);
if (isset($string2) && !empty($string2)) {
$imagecaption_elt = $doc->createElement('image:caption', $string2);
$image_elt->appendChild($imagecaption_elt);
}
}
}
$lastmod_elt = $doc->createElement('lastmod', $currentDate);
$changefreq_elt = $doc->createElement('changefreq', $changefreq);
$priority_elt = $doc->createElement('priority', $priority);
$url_elt->appendChild($lastmod_elt);
$url_elt->appendChild($changefreq_elt);
$url_elt->appendChild($priority_elt);
if ($isCheckLink && $this->isLinkDead($urlPage)) { $countNOk++;
} else { $countOk++; }
}
}
}
}
} catch (Zend_Exception $e) {
$this->log('Erreur lors de la generation du sitemapAddUrlProducts : '.$e->getMessage(),'err');
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => $e->getMessage());
}
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => 'SUCCESS');
}
private function sitemapAddUrlCategories($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom, $isImage, $isCheckLink) {
try {
$countOk = 0;
$countNOk = 0;
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_CustomAccent())
->addFilter(new Zend_Filter_Alnum(array('allowwhitespace' => true)));
$sql = "SELECT c.ID ID, c.NOM NOM, c.URL URL, c.NAVNOM NAVNOM, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS
FROM category c WHERE c.isACTIVE = 1";
$categorie = new Category();
$listCats = $categorie->getAdapter()->fetchAll($sql);
$date = new Zend_Date();
$currentDate = $date->toString('YYYY-MM-dd');
$type = 1;
foreach ($listCats as $row) {
$url_elt = $doc->createElement('url');
$body_elt->appendChild($url_elt);
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$urlPage = $this->getUrlPageCategory(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'], 'PAGE' => $navnom, 'ID' => $row['ID'], 'TYPE' => $type));
$loc_elt = $doc->createElement('loc', $urlPage);
$url_elt->appendChild($loc_elt);
if ($isImage) {
if (isset($row['URL']) && !empty($row['URL'])) {
$image_elt = $doc->createElement('image:image');
$url_elt->appendChild($image_elt);
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$row['URL'];
$imageloc_elt = $doc->createElement('image:loc',$urlImage);
$image_elt->appendChild($imageloc_elt);
$string1 = $filter->filter($row['NOM']);
if (isset($string1) && !empty($string1)) {
$imagetitle_elt = $doc->createElement('image:title', $string1);
$image_elt->appendChild($imagetitle_elt);
}
}
}
$lastmod_elt = $doc->createElement('lastmod', $currentDate);
$changefreq_elt = $doc->createElement('changefreq', $changefreq);
$priority_elt = $doc->createElement('priority', $priority);
$url_elt->appendChild($lastmod_elt);
$url_elt->appendChild($changefreq_elt);
$url_elt->appendChild($priority_elt);
if ($isCheckLink && $this->isLinkDead($urlPage)) { $countNOk++;
} else { $countOk++; }
}
} catch (Zend_Exception $e) {
$this->log('Erreur lors de la generation du sitemapAddUrlCategories : '.$e->getMessage(),'err');
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => $e->getMessage());
}
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => 'SUCCESS');
}
private function sitemapAddUrlCategories2($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom, $isImage, $isCheckLink) {
try {
$countOk = 0;
$countNOk = 0;
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_CustomAccent())
->addFilter(new Zend_Filter_Alnum(array('allowwhitespace' => true)));
$sql = "SELECT c.ID ID, c.NOM NOM, c.URL URL, c.NAVNOM NAVNOM, c.NAVNOM_URLPARENTS NAVNOM_URLPARENTS
FROM category2 c WHERE c.isACTIVE = 1";
$categorie = new Category();
$listCats = $categorie->getAdapter()->fetchAll($sql);
$date = new Zend_Date();
$currentDate = $date->toString('YYYY-MM-dd');
$type = 2;
foreach ($listCats as $row) {
$url_elt = $doc->createElement('url');
$body_elt->appendChild($url_elt);
$navnom = $this->verifyNavigationString($row['NAVNOM'], $row['NOM'], '');
$urlPage = $this->getUrlPageCategory(array('NAVNOM_URLPARENTS' => $row['NAVNOM_URLPARENTS'], 'PAGE' => $navnom, 'ID' => $row['ID'], 'TYPE' => $type));
$loc_elt = $doc->createElement('loc', $urlPage);
$url_elt->appendChild($loc_elt);
if ($isImage) {
if (isset($row['URL']) && !empty($row['URL'])) {
$image_elt = $doc->createElement('image:image');
$url_elt->appendChild($image_elt);
$urlImage = $this->baseUrl_SiteCommerceUrl."/".$row['URL'];
$imageloc_elt = $doc->createElement('image:loc',$urlImage);
$image_elt->appendChild($imageloc_elt);
$string1 = $filter->filter($row['NOM']);
if (isset($string1) && !empty($string1)) {
$imagetitle_elt = $doc->createElement('image:title', $string1);
$image_elt->appendChild($imagetitle_elt);
}
}
}
$lastmod_elt = $doc->createElement('lastmod', $currentDate);
$changefreq_elt = $doc->createElement('changefreq', $changefreq);
$priority_elt = $doc->createElement('priority', $priority);
$url_elt->appendChild($lastmod_elt);
$url_elt->appendChild($changefreq_elt);
$url_elt->appendChild($priority_elt);
if ($isCheckLink && $this->isLinkDead($urlPage)) {
$countNOk++;
} else { $countOk++; }
}
}
catch (Zend_Exception $e) {
$this->log('Erreur lors de la generation du sitemapAddUrlCategories2 : '.$e->getMessage(),'err');
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => $e->getMessage());
}
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => 'SUCCESS');
}
private function sitemapAddUrlInfos($doc, $body_elt, $changefreq, $priority, $isDupliateByNavNom,$isImage, $isCheckLink) {
try {
$countOk = 0;
$countNOk = 0;
$footers = new FooterContent();
$listFooter = $footers->fetchAll();
$date = new Zend_Date();
$currentDate = $date->toString('YYYY-MM-dd');
$type = 1;
foreach ($listFooter AS $row) {
$urlPage = $this->getUrlPageInfo(array('TITRE' => $row['TITRE'], 'ID' => $row['ID'], 'URL' => $row['URL'], 'TYPE' => $type));
$url_elt = $doc->createElement('url');
$body_elt->appendChild($url_elt);
$loc_elt = $doc->createElement('loc', $urlPage);
$url_elt->appendChild($loc_elt);
$lastmod_elt = $doc->createElement('lastmod', $currentDate);
$changefreq_elt = $doc->createElement('changefreq', $changefreq);
$priority_elt = $doc->createElement('priority', $priority);
$url_elt->appendChild($lastmod_elt);
$url_elt->appendChild($changefreq_elt);
$url_elt->appendChild($priority_elt);
if ($isCheckLink && $this->isLinkDead($urlPage)) { $countNOk++;
} else { $countOk++; }
}
} catch (Zend_Exception $e) {
$this->log('Erreur lors de la generation du sitemapAddUrlInfos : '.$e->getMessage(),'err');
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => $e->getMessage());
}
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => 'SUCCESS');
}
private function sitemapAddUrlDefault($doc, $body_elt, $isCheckLink) {
try {
$countOk = 0;
$countNOk = 0;
$date = new Zend_Date();
$currentDate = $date->toString('YYYY-MM-dd');
$addArray = array();
$addArray[0]['loc'] = $this->baseUrl_SiteCommerceUrl."/";
$addArray[0]['changefreq'] = "monthly";
$addArray[0]['priority'] = "0.9";
$addArray[1]['loc'] = $this->baseUrl_SiteCommerceUrl."/mon-panier.html";
$addArray[1]['changefreq'] = "monthly";
$addArray[1]['priority'] = "0.9";
$addArray[2]['loc'] = $this->baseUrl_SiteCommerceUrl."/connectez-vous.html";
$addArray[2]['changefreq'] = "monthly";
$addArray[2]['priority'] = "0.9";
$addArray[3]['loc'] = $this->baseUrl_SiteCommerceUrl."/enregistrez-vous.html";
$addArray[3]['changefreq'] = "monthly";
$addArray[3]['priority'] = "0.9";
$addArray[4]['loc'] = $this->baseUrl_SiteCommerceUrl."/services/faq/";
$addArray[4]['changefreq'] = "monthly";
$addArray[4]['priority'] = "0.9";
$addArray[5]['loc'] = $this->baseUrl_SiteCommerceUrl."/retrouver-mon-mot-de-passe.html";
$addArray[5]['changefreq'] = "monthly";
$addArray[5]['priority'] = "0.9";
for ($i = 0; $i < sizeof($addArray); $i++) {
$url_elt = $doc->createElement('url');
$body_elt->appendChild($url_elt);
$loc_elt = $doc->createElement('loc', $addArray[$i]['loc']);
$url_elt->appendChild($loc_elt);
$lastmod_elt = $doc->createElement('lastmod', $currentDate);
$changefreq_elt = $doc->createElement('changefreq', $addArray[$i]['changefreq']);
$priority_elt = $doc->createElement('priority', $addArray[$i]['priority']);
$url_elt->appendChild($lastmod_elt);
$url_elt->appendChild($changefreq_elt);
$url_elt->appendChild($priority_elt);
if ($isCheckLink && $this->isLinkDead($addArray[$i]['loc'])) { $countNOk++;
} else { $countOk++; }
}
} catch (Zend_Exception $e) {
$this->log('Erreur lors de la generation du sitemapAddUrlDefault : '.$e->getMessage(),'err');
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => $e->getMessage());
}
return array('OK' => $countOk, 'NOK' => $countNOk, 'RESULT' => 'SUCCESS');
}
private function cleanUp($value) {
$result = $value;
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags());
$result =$filter->filter($result);
$result = html_entity_decode($result,ENT_QUOTES,"ISO-8859-1");
$result = str_replace("\r\n", "", $result);
$result = str_replace('"',"'",$result);
$result = str_replace(';',"'",$result);
return $result;
}
private function getUrlPage($params) {
//produit
return $this->baseUrl_SiteCommerceUrl."/".Utils_Tool::getFormattedUrlProduct($params['NAVNOM_URLPARENTS'], $params['PAGE'], $params['ID']);
}
private function getUrlPageProduct($params) {
//produit
switch ($params['TYPE']) {
case 1 :
return $this->baseUrl_SiteCommerceUrl."/".Utils_Tool::getFormattedUrlProduct($params['NAVNOM_URLPARENTS'], $params['PAGE'], $params['ID']);
break;
}
}
private function getUrlPageCategory($params) {
//category
switch ($params['TYPE']) {
case 1 :
return $this->baseUrl_SiteCommerceUrl."/".Utils_Tool::getFormattedUrlCategory($params['NAVNOM_URLPARENTS'], $params['PAGE'], $params['ID']);
break;
case 1 :
return $this->baseUrl_SiteCommerceUrl."/".Utils_Tool::getFormattedUrlCategory2($params['NAVNOM_URLPARENTS'], $params['PAGE'], $params['ID']);
break;
}
}
private function getUrlPageInfo($params) {
//Info
$navnom = $this->verifyNavigationString("", $params['TITRE'], "");
$urlPage = "";
if (empty($params['URL'])) {
switch ($params['TYPE']) {
case 1 :
$urlPage = $this->baseUrl_SiteCommerceUrl."/info-".$params['ID']."/".$navnom.".html";
break;
}
} else {
$urlPage = "http://".$params['URL'];
}
return $urlPage;
}
}
?>PK �0H[�ۻ�� �� PromotionController.phpnu &1i� <?php
class Backoffice_PromotionController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Promos";
$this->isConnectedWithRole('isPromo');
}
function indexAction()
{
$this->_forward('/product');
}
function frontAction()
{
$this->view->titlePage = "Les promotions de la page d'Accueil";
$promoFront = new PromoFront();
$listFrontSQL = "
SELECT p.NOM NOM, p.DESCRIPTIONSHORT DESCSHORT, p.ID IDPRODUCT,
pf.REFERENCE REFERENCE, pf.POSITION POSITION, pf.ID ID
FROM promo_front AS pf
LEFT JOIN productchild AS pc ON pc.REFERENCE = pf.REFERENCE
LEFT JOIN product AS p ON pc.IDPRODUCT = p.ID
ORDER BY pf.POSITION ASC";
$listFront = $promoFront->getAdapter()->fetchAll($listFrontSQL);
$this->view->listFront = $listFront;
}
function frontaddAction()
{
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$promoFront = new PromoFront();
$productChild = new ProductChild();
$params = array();
$params = $this->getRequest()->getPost();
if ($validator->isValid($params['reference']))
{
$isExistProduct = $productChild->fetchRow("REFERENCE = '".$params['reference']."'");
if ($isExistProduct ) {
if ($isExistProduct['isPROMO'] == 0) {
$isExistFront = $promoFront->fetchRow("REFERENCE = '".$params['reference']."'");
if (!$isExistFront) {
$date = new Zend_Date();
$data = array (
'REFERENCE' => $filter->filter($params['reference']),
'POSITION' => (int)$params['position'],
'DATEINSERTPROMO' => $date->toString('YYYY-MM-dd HH-mm-ss')
);
$promoFront->insert($data);
} else {
$this->view->messageError = "Le produit est d�j� affich�";
}
} else {
$this->view->messageError = "La r�f�rence n'est pas en promotion";
}
} else {
$this->view->messageError = "La r�f�rence ".$params['reference']." n'existe pas.";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('front');
}
function fronteditAction() {
if ($this->getRequest()->isPost()) {
$promoFront = new PromoFront();
$params = $this->getRequest()->getPost();
$date = new Zend_Date();
$data = array (
'DATEINSERTPROMO' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'POSITION' => (int)$params['position']
);
$promoFront->update($data,'ID = '.$params['promoid']);
$this->view->messageSuccess = "Le produit est affich�";
}
$this->_forward('front');
}
function frontdelAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$promoFront = new PromoFront();
$promoFront->delete('ID = '.$id);
$this->view->messageSuccess = "L'article n'est plus affich� sur la page d'accueil";
}
}
$this->_forward('front');
}
function productAction() {
$this->view->titlePage = "Les promotions sur les Produits";
$supplierBrend = new SupplierBrend();
$this->view->listbrend = $supplierBrend->fetchAll($supplierBrend->select()->order('BREND ASC'));
$promoProduct = new PromoProduct();
//Promo par article
$listPromo1SQL = "
SELECT p.NOM NOM, p.DESCRIPTIONSHORT DESCSHORT, p.ID ID, ppc.ID IDPROMO,
pc.REFERENCE REFERENCE, ppc.REMISEEURO REMISEEURO, ppc.REMISEPOUR REMISEPOUR
FROM promo_productchild AS ppc
LEFT JOIN productchild AS pc ON pc.REFERENCE = ppc.REFERENCE
LEFT JOIN product AS p ON pc.IDPRODUCT = p.ID
WHERE ppc.REFERENCE IS NOT NULL
ORDER BY pc.REFERENCE ASC";
$listPromo1 = $promoProduct->getAdapter()->fetchAll($listPromo1SQL);
$this->view->listPromo1 = $listPromo1;
//Promotion sur X selon Y
$listPromo2SQL = "
SELECT ppc.REMISEEURO REMISEEURO, ppc.REMISEPOUR REMISEPOUR,ppc.ID IDPROMO,
ppc.CHILDREFBUY CHILDREFBUY, ppc.CHILDREFPROMO CHILDREFPROMO,
ppc.CHILDREFBUYNB CHILDREFBUYNB, ppc.CHILDREFPROMONB CHILDREFPROMONB
FROM promo_productchild AS ppc
WHERE ppc.CHILDREFBUY IS NOT NULL
AND ppc.CHILDREFPROMO IS NOT NULL
ORDER BY ppc.CHILDREFBUY, ppc.CHILDREFPROMO ASC";
$this->view->listPromo2 = $promoProduct->getAdapter()->fetchAll($listPromo2SQL);
//Promotion Date
$listPromo3SQL = "
SELECT ppc.DATEPROMOSTART DATEPROMOSTART, ppc.DATEPROMOEND DATEPROMOEND,ppc.ID IDPROMO,
ppc.REMISEEURO REMISEEURO, ppc.REMISEPOUR REMISEPOUR
FROM promo_productchild AS ppc
WHERE ppc.DATEPROMOSTART IS NOT NULL
AND ppc.DATEPROMOEND IS NOT NULL
ORDER BY ppc.DATEPROMOSTART, ppc.DATEPROMOEND ASC";
$this->view->listPromo3 = $promoProduct->getAdapter()->fetchAll($listPromo3SQL);
//Promotion Gamme
$listPromo4SQL = "
SELECT c.NOM NOMCATEGORY, c.ID IDCATEGORY, ppc.ID IDPROMO,
ppc.REMISEEURO REMISEEURO, ppc.REMISEPOUR REMISEPOUR
FROM promo_productchild AS ppc
LEFT JOIN category AS c ON c.ID = ppc.IDCATEGORY
WHERE ppc.IDCATEGORY IS NOT NULL
ORDER BY c.NOM ASC";
$this->view->listPromo4 = $promoProduct->getAdapter()->fetchAll($listPromo4SQL);
//Promotion Marque
$listPromo5SQL = "
SELECT sb.BREND BREND, sb.ID IDBREND, ppc.ID IDPROMO,
ppc.REMISEEURO REMISEEURO, ppc.REMISEPOUR REMISEPOUR
FROM promo_productchild AS ppc
LEFT JOIN supplier_brend AS sb ON sb.ID = ppc.IDBREND
WHERE ppc.IDBREND IS NOT NULL
ORDER BY sb.BREND ASC";
$this->view->listPromo5 = $promoProduct->getAdapter()->fetchAll($listPromo5SQL);
}
function productdelAction() {
try {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$promoProduct = new PromoProduct();
$promoProduct->delete('ID = '.$id);
$this->view->messageSuccess = "La promotion a �t� supprim�e ";
} else {
$this->view->messageError = "La promotion n'a pas �t� supprim�e ";
}
}
if ($this->getRequest()->getParam('idref')) {
$idRef = (int)$this->getRequest()->getParam('idref');
if ($idRef > 0 ) {
$promoProduct = new PromoProduct();
$productChild = new ProductChild();
$resultSQL = "
SELECT p.NOM NOM,p.ID IDPRODUCT, p.isPROMO isPROMOPRODUCT,
pp.ID, pp.REFERENCE REFERENCE
FROM promo_productchild AS pp
LEFT JOIN productchild AS pc ON pc.REFERENCE = pp.REFERENCE
LEFT JOIN product AS p ON pc.IDPRODUCT = p.ID
WHERE pp.ID = ".$idRef;
$result = $promoProduct->getAdapter()->fetchRow($resultSQL);
$data = array (
'isPROMO' => 1
);
$productChild->update($data,"REFERENCE = '".$result['REFERENCE']."'");
$isLastPromo = $productChild->fetchRow("isPROMO = 0 AND IDPRODUCT = ".$result['IDPRODUCT']);
if (!$isLastPromo) {
$product = new Product();
$product->update($data,"ID = ".$result['IDPRODUCT']);
}
$promoProduct->delete('ID = '.$idRef);
$this->view->messageSuccess = "La promotion a �t� supprim�e ";
} else {
$this->view->messageError = "La promotion n'a pas �t� supprim�e ";
}
}
} catch (Zend_Exception $e) {
$this->log('productdelAction : '.$e->getMessage(),'err');
}
$this->_forward('product');
}
function productaddAction() {
try {
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$promoProduct = new PromoProduct();
$productChild = new ProductChild();
$params = array();
$params = $this->getRequest()->getPost();
$remiseeuro = !empty($params['remiseeuro']) ? $params['remiseeuro'] : 0;
$remisepour = (int)$params['remisepour'];
$isOK = true;
if ($remiseeuro > 0 && $remisepour > 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($remiseeuro == 0 && $remisepour == 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE et est obligatoire. ";
$isOK = false;
}
if (($validator->isValid($remiseeuro) ||
$validator->isValid($remisepour)) && $isOK == true
) {
switch ($params['promo']) {
case 1 :
if ($validator->isValid($params['reference'])) {
$isExistChild = $productChild->fetchRow("REFERENCE = '".$params['reference']."'");
$isExistPromo = $promoProduct->fetchRow("REFERENCE = '".$params['reference']."'");
if ($isExistChild) {
if ($isExistPromo) {
$this->view->messageError = "La r�f�rence : ".$params['reference']." est d�ja en promotion. ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTPROMO' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'REFERENCE' => $filter->filter($params['reference'])
);
$promoProduct->insert($data);
$product = new Product();
$data2 = array (
'isPROMO' => 0
);
$product->update($data2, 'ID = '.$isExistChild['IDPRODUCT']);
$productChild->update($data2, "REFERENCE = '".$isExistChild['REFERENCE']."'");
$this->view->messageSuccess = "La r�f�rence : ".$data['REFERENCE']." est maintenant est promotion. ";
}
} else {
$this->view->messageError = "La r�f�rence : ".$params['reference']." n'existe pas. ";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
break;
case 2 :
if ($validator->isValid($params['referencebuy']) &&
$validator->isValid($params['referencepromo']) &&
((int)$params['referencepromonb']>0) &&
((int)$params['referencebuynb']>0)
) {
$isExistChild1 = $productChild->fetchRow("REFERENCE = '".$params['referencebuy']."'");
$isExistChild2 = $productChild->fetchRow("REFERENCE = '".$params['referencepromo']."'");
if ($isExistChild1 && $isExistChild2 && $params['referencebuy'] != $params['referencepromo']) {
$isExistPromo = $promoProduct->fetchRow("CHILDREFBUY = '".$params['referencebuy']."' AND CHILDREFPROMO = '".$params['referencepromo']."'");
if ($isExistPromo) {
$this->view->messageError = "La r�f�rence : ".$params['referencepromo']." est d�j� en promotion. ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTPROMO' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'CHILDREFBUY' => $filter->filter($params['referencebuy']),
'CHILDREFPROMO' => $filter->filter($params['referencepromo']),
'CHILDREFPROMONB' => $filter->filter((int)$params['referencepromonb']),
'CHILDREFBUYNB' => $filter->filter((int)$params['referencebuynb'])
);
$promoProduct->insert($data);
$this->view->messageSuccess = "Si <b>".$data['CHILDREFBUYNB']."</b> articles de <b>".$data['CHILDREFBUY']."</b> sont achet�s alors <b>".$data['CHILDREFPROMONB']."</b> articles de <b>".$data['CHILDREFPROMO']."</b> sont en promotion ";
}
} else {
if ($params['referencebuy'] == $params['referencepromo']) {
$this->view->messageError = "Les r�f�rences sont identiques";
} else {
$this->view->messageError = "La r�f�rence : ".$params['referencebuy']." ou ".$params['referencepromo']." n'existe pas. ";
}
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
break;
case 3 :
$validator->addValidator(new Zend_Validate_Date());
if ($validator->isValid($params['sd']) &&
$validator->isValid($params['ed'])
) {
$isExistPromo = $promoProduct->fetchRow("DATEPROMOSTART = '".$params['sd']."' AND DATEPROMOEND = '".$params['ed']."' ");
if ($isExistPromo) {
$this->view->messageError = "La promotion pour cette p�riode existe d�j� ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTPROMO' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'DATEPROMOSTART' => $filter->filter($params['sd']),
'DATEPROMOEND' => $filter->filter($params['ed'])
);
$promoProduct->insert($data);
$this->view->messageSuccess = "Les produits o� la date de promotion est comprise entre ".$params['sd']." et ".$params['ed']." sont en promotions. ";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
break;
case 4 :
if ($params['listcategory'] > 0 ) {
$isExistPromo = $promoProduct->fetchRow("IDCATEGORY = ".$params['listcategory']);
if ($isExistPromo) {
$this->view->messageError = "La promotion pour cette gamme existe d�j� ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTPROMO' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'IDCATEGORY' => $filter->filter($params['listcategory'])
);
$promoProduct->insert($data);
$this->view->messageSuccess = "Les produits de la gamme sont maintenant en promotion. ";
}
} else {
$this->view->messageError = "S�lectionner une cat�gorie";
}
break;
case 5 :
if ($params['listbrend'] > 0 ) {
$isExistPromo = $promoProduct->fetchRow("IDBREND = ".$params['listbrend']);
if ($isExistPromo) {
$this->view->messageError = "La promotion pour cette marque existe d�j� ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTPROMO' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'REMISEEURO' => $remiseeuro,
'REMISEPOUR' => $remisepour,
'IDBREND' => $filter->filter($params['listbrend'])
);
$promoProduct->insert($data);
$this->view->messageSuccess = "Les produits de la marque sont maintenant en promotion. ";
}
} else {
$this->view->messageError = "S�lectionner une marque";
}
break;
default:
$this->_forward('product');
break;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
} catch (Zend_Exception $e) {
$this->log('productaddAction : '.$e->getMessage(),'err');
$this->view->messageError = "V�rifier les param�tres";
}
$this->_forward('product');
}
function commandAction() {
$this->view->titlePage = "Les remises sur les Commandes";
$promoCommand = new PromoCommand();
$isAll = $promoCommand->fetchRow('isALL = 0 AND isALL IS NOT NULL');
if ($isAll) {
$this->view->remiseAll = $isAll;
}
$isMontant = $promoCommand->fetchRow('MONTANTEQUAL > 0 AND MONTANTEQUAL IS NOT NULL');
if ($isMontant) {
$this->view->remiseMontant = $isMontant;
}
$listRemise1SQL = "
SELECT p.NOM NOM,p.ID IDPRODUCT, p.DESCRIPTIONSHORT DESCSHORT, prc.ID ID,prc.CHILDNBR CHILDNBR,
prc.CHILDREFERENCE CHILDREFERENCE, prc.REMISEEURO REMISEEURO, prc.REMISEPOUR REMISEPOUR
FROM promo_command AS prc
LEFT JOIN productchild AS pc ON pc.REFERENCE = prc.CHILDREFERENCE
LEFT JOIN product AS p ON pc.IDPRODUCT = p.ID
WHERE prc.CHILDREFERENCE IS NOT NULL
ORDER BY prc.CHILDREFERENCE ASC";
$listRemise1 = $promoCommand->getAdapter()->fetchAll($listRemise1SQL);
$this->view->listRemise1 = $listRemise1;
}
function commandaddAction() {
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$promoCommand = new PromoCommand();
$productChild = new ProductChild();
$params = array();
$params = $this->getRequest()->getPost();
if ($params['remise'] == '5') {
if (isset($params['montantfrais']) && (int)$params['montantfrais'] > 0 && $validator->isValid($params['montantfrais'])) {
$isExistFrais = $promoCommand->fetchRow("MONTANTVALID IS NOT NULL");
if ($isExistFrais) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTVALID' => $filter->filter($params['montantfrais'])
);
$promoCommand->update($data,'ID = '.$isExistFrais['ID']);
$this->view->messageSuccess = "La validit� de la commande a �t� modifi�e ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTVALID' => $filter->filter($params['montantfrais'])
);
$promoCommand->insert($data);
$this->view->messageSuccess = "La validit� de la commande a �t� modifi�e ";
}
} else {
$this->view->messageError = "Le montant de la commande doit etre sup�rieur � 0";
}
}
if (isset($params['remisepour']) && isset($params['remiseeuro'])) {
$remiseeuro = (int)$params['remiseeuro'];
$remisepour = (int)$params['remisepour'];
$isOK = true;
if ($remiseeuro > 0 && $remisepour > 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($remiseeuro == 0 && $remisepour == 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE et est obligatoire. ";
$isOK = false;
}
if (($validator->isValid($remiseeuro) ||
$validator->isValid($remisepour)) && $isOK == true
) {
switch ($params['remise']) {
case 1 :
$isExistAll = $promoCommand->fetchRow("isALL IS NOT NULL");
if ($isExistAll) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'isALL' => '0',
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoCommand->update($data,'ID = '.$isExistAll['ID']);
$this->view->messageSuccess = "Toutes les commandes ont maintenant une remise ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'isALL' => '0',
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoCommand->insert($data);
$this->view->messageSuccess = "Toutes les commandes ont maintenant une remise ";
}
break;
case 2 :
if ($validator->isValid($params['montant']) &&
(int)$params['montant'] > 0
) {
$isExistMontant = $promoCommand->fetchRow("MONTANTEQUAL IS NOT NULL");
if ($isExistMontant) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTEQUAL' => $filter->filter($params['montant']),
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoCommand->update($data,'ID = '.$isExistMontant['ID']);
$this->view->messageSuccess = "Toutes les commandes ont maintenant une remise ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTEQUAL' => $filter->filter($params['montant']),
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoCommand->insert($data);
$this->view->messageSuccess = "Toutes les commandes ont maintenant une remise ";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
break;
case 3 :
if ($validator->isValid($params['nbrreference']) &&
$validator->isValid($params['reference']) &&
(int)$params['nbrreference'] > 0
) {
$isExistReferenceChild = $productChild->fetchRow("REFERENCE = '".$params['reference']."' ");
if ($isExistReferenceChild) {
$isExistReference = $promoCommand->fetchRow("CHILDREFERENCE = '".$params['reference']."' ");
if ($isExistReference) {
$this->view->messageError = "Les commandes ont d�j� une remise sur cet article ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'CHILDREFERENCE' => $filter->filter($params['reference']),
'CHILDNBR' => $filter->filter($params['nbrreference']),
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoCommand->insert($data);
$this->view->messageSuccess = "Toutes les commandes ont maintenant une remise ";
}
} else {
$this->view->messageError = "La r�f�rence ".$params['reference']." n'existe pas";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
if ((int)$params['nbrreference'] == 0) {
$this->view->messageError .= "Le nombre d'articles doit etre sup�rieur � 0";
}
}
break;
case 4 :
if (isset($params['montantfrais']) && (int)$params['montantfrais'] > 0) {
$isExistFrais = $promoCommand->fetchRow("MONTANTFRAISCMD IS NOT NULL AND MONTANTFRAISCMD = ".$params['montantfrais']);
if ($isExistFrais) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTFRAISCMD' => $filter->filter($params['montantfrais']),
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoCommand->update($data,'ID = '.$isExistFrais['ID']);
$this->view->messageSuccess = "Les frais de livraison sont modifi�s ";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'MONTANTFRAISCMD' => $filter->filter($params['montantfrais']),
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoCommand->insert($data);
$this->view->messageSuccess = "Les frais de livraison sont modifi�s ";
}
} else {
$this->view->messageError = "Le montant de la commande doit etre sup�rieur � 0";
}
break;
default:
$this->_forward('command');
break;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
}
$this->_forward('command');
}
function commanddelAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$promoCommand = new PromoCommand();
$promoCommand->delete('ID = '.$id);
$this->view->messageSuccess = "La remise a �t� supprim�e ";
} else {
$this->view->messageError = "La remise n'a pas �t� supprim�e ";
}
}
$this->_forward('command');
}
function userAction() {
$this->view->titlePage = "Les remises des Clients";
$promoUser = new PromoUser();
$user = new User();
$supplierBrend = new SupplierBrend();
$this->view->listbrend = $supplierBrend->fetchAll($supplierBrend->select()->order('BREND ASC'));
$codeIntern = new CodeIntern();
$this->view->listAllCIntern = $codeIntern->fetchAll($codeIntern->select()->order('CODE ASC'));
$listAllUserSQL = "
SELECT u.NOM NOM,u.ID IDUSER, u.PRENOM PRENOM
FROM user AS u
ORDER BY u.NOM, u.PRENOM ASC";
$listAllUser = $user->getAdapter()->fetchAll($listAllUserSQL);
if ($listAllUser) {
$this->view->listAllUser = $listAllUser;
}
$listUserSQL = "
SELECT u.NOM NOM,u.ID IDUSER, u.PRENOM PRENOM,
pu.ID ID, pu.REMISEEURO REMISEEURO, pu.REMISEPOUR REMISEPOUR
FROM promo_user AS pu
LEFT JOIN user AS u ON u.ID = pu.IDUSER
WHERE pu.IDUSER IS NOT NULL
ORDER BY u.NOM, u.PRENOM ASC";
$listUser = $promoUser->getAdapter()->fetchAll($listUserSQL);
if ($listUser) {
$this->view->listUser = $listUser;
}
$isDateInsc = $promoUser->fetchRow('isDATEINSCR = 0');
if ($isDateInsc) {
$this->view->dateInsc = $isDateInsc;
}
$isFirstCmd = $promoUser->fetchRow('isFIRSTCMD = 0');
if ($isFirstCmd) {
$this->view->firstCmd = $isFirstCmd;
}
$listUserBrendSQL = "
SELECT u.NOM NOM,u.ID IDUSER, u.PRENOM PRENOM,
pu.ID ID, pu.REMISEEURO REMISEEURO, pu.REMISEPOUR REMISEPOUR, pu.USERIDBREND USERIDBREND, pu.USERBRENDID USERBRENDID, sb.BREND BREND, sb.IDSUPPLIER IDSUPPLIER
FROM promo_user AS pu
LEFT JOIN user AS u ON u.ID = pu.USERIDBREND
LEFT JOIN supplier_brend AS sb ON sb.ID = pu.USERBRENDID
WHERE pu.USERIDBREND IS NOT NULL
AND pu.USERBRENDID IS NOT NULL
ORDER BY u.NOM, u.PRENOM ASC";
$listUserBrend = $promoUser->getAdapter()->fetchAll($listUserBrendSQL);
if ($listUserBrend) {
$this->view->listUserBrend = $listUserBrend;
}
$listCinternBrendSQL = "
SELECT pu.ID ID, pu.REMISEEURO REMISEEURO, pu.REMISEPOUR REMISEPOUR, uci.LABEL LABELINTERN, uci.CODE CODEINTERN,
pu.CINTERNIDBREND CINTERNIDBREND, sb.BREND BREND, pu.CINTERNBRENDID CINTERNBRENDID, sb.IDSUPPLIER IDSUPPLIER
FROM promo_user AS pu
LEFT JOIN user_cintern AS uci ON uci.ID = pu.CINTERNIDBREND
LEFT JOIN supplier_brend AS sb ON sb.ID = pu.CINTERNBRENDID
WHERE pu.CINTERNIDBREND IS NOT NULL
AND pu.CINTERNBRENDID IS NOT NULL
ORDER BY uci.CODE,sb.BREND ASC";
$listCinternBrend = $promoUser->getAdapter()->fetchAll($listCinternBrendSQL);
if ($listCinternBrend) {
$this->view->listCinternBrend = $listCinternBrend;
}
}
function useraddAction() {
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$promoUser = new PromoUser();
$params = array();
$params = $this->getRequest()->getPost();
$remiseeuro = (int)$params['remiseeuro'];
$remisepour = (int)$params['remisepour'];
$isOK = true;
if ($remiseeuro > 0 && $remisepour > 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($remiseeuro == 0 && $remisepour == 0) {
$this->view->messageError = "La remise est soit en EURO, soit en POURCENTAGE et est obligatoire. ";
$isOK = false;
}
if (($validator->isValid($remiseeuro) ||
$validator->isValid($remisepour)) && $isOK == true
) {
switch ($params['remise']) {
case 1 :
$isExistAnnif = $promoUser->fetchRow("isDATEINSCR IS NOT NULL");
if ($isExistAnnif) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'isDATEINSCR' => '0',
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->update($data,'ID = '.$isExistAnnif['ID']);
$this->view->messageSuccess = "Tout les clients ont maintenant une remise selon leurs dates d'inscription";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'isDATEINSCR' => '0',
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->insert($data);
$this->view->messageSuccess = "Tout les clients ont maintenant une remise selon leurs dates d'inscription";
}
break;
case 2 :
$isExistFirst = $promoUser->fetchRow("isFIRSTCMD IS NOT NULL");
if ($isExistFirst) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'isFIRSTCMD' => '0',
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->update($data,'ID = '.$isExistFirst['ID']);
$this->view->messageSuccess = "Tout les clients ont maintenant une remise si c'est la premi�re commande";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'isFIRSTCMD' => '0',
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->insert($data);
$this->view->messageSuccess = "Tout les clients ont maintenant une remise si c'est la premi�re commande";
}
break;
case 3 :
$iduser = (int)$params['iduser'];
if ($iduser > 0) {
$isExistUser = $promoUser->fetchRow("IDUSER IS NOT NULL AND IDUSER = ".$iduser);
if ($isExistUser) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'IDUSER' => (int)$params['iduser'],
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->update($data,'ID = '.$isExistUser['ID']);
$this->view->messageSuccess = "Le client � maintenant une remise sur sa prochaine commande";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'IDUSER' => (int)$params['iduser'],
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->insert($data);
$this->view->messageSuccess = "Le client � maintenant une remise sur sa prochaine commande";
}
} else {
$this->view->messageError = "S�lectionner un utilisateur";
}
break;
case 4 :
$iduser = (int)$params['iduser'];
$idbrend = (int)$params['idbrend'];
if ($iduser > 0 && $idbrend > 0) {
$isExistUserBrend = $promoUser->fetchRow("USERIDBREND IS NOT NULL AND USERIDBREND = ".$iduser." AND USERBRENDID IS NOT NULL AND USERBRENDID = ".$idbrend);
if ($isExistUserBrend) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'USERIDBREND' => $iduser,
'USERBRENDID' => $idbrend,
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->update($data,'ID = '.$isExistUserBrend['ID']);
$this->view->messageSuccess = "Le client � maintenant une remise sur les produits de la marque";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'USERIDBREND' => $iduser,
'USERBRENDID' => $idbrend,
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->insert($data);
$this->view->messageSuccess = "Le client � maintenant une remise sur les produits de la marque";
}
} else {
$this->view->messageError = "S�lectionner un client et une marque";
}
break;
case 5 :
$idcintern = (int)$params['idcintern'];
$idbrend = (int)$params['idbrend'];
if ($idcintern > 0 && $idbrend > 0) {
$isExistCinternBrend = $promoUser->fetchRow("CINTERNIDBREND IS NOT NULL AND CINTERNIDBREND = ".$idcintern." AND CINTERNBRENDID IS NOT NULL AND CINTERNBRENDID = ".$idbrend);
if ($isExistCinternBrend) {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'CINTERNIDBREND' => $idcintern,
'CINTERNBRENDID' => $idbrend,
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->update($data,'ID = '.$isExistCinternBrend['ID']);
$this->view->messageSuccess = "Le code interne a maintenant une remise sur les produits de la marque";
} else {
$date = new Zend_Date();
$data = array (
'DATEINSERTREMISE' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'CINTERNIDBREND' => $idcintern,
'CINTERNBRENDID' => $idbrend,
'REMISEEURO' => $filter->filter($params['remiseeuro']),
'REMISEPOUR' => $filter->filter($params['remisepour'])
);
$promoUser->insert($data);
$this->view->messageSuccess = "Le code interne � maintenant une remise sur les produits de la marque";
}
} else {
$this->view->messageError = "S�lectionner un code interne et une marque";
}
break;
default:
$this->_forward('user');
break;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('user');
}
function userdelAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$promoUser = new PromoUser();
$promoUser->delete('ID = '.$id);
$this->view->messageSuccess = "La remise a �t� supprim�e ";
} else {
$this->view->messageError = "La remise n'a pas �t� supprim�e ";
}
}
$this->_forward('user');
}
function giftAction() {
$this->view->titlePage = "Les Avantages";
$promoGift = new PromoGift();
$listProductGiftSQL = "
SELECT pg.PRODREFBUY PRODREFBUY, pg.PRODREFGIFT PRODREFGIFT,pg.ID ID,
pg.PRODNBBUY PRODNBBUY,pg.PRODNBGIFT PRODNBGIFT
FROM promo_gift AS pg
WHERE pg.PRODREFBUY IS NOT NULL
AND pg.PRODREFGIFT IS NOT NULL
ORDER BY pg.PRODREFBUY, pg.PRODREFGIFT ASC";
$listProductGift = $promoGift->getAdapter()->fetchAll($listProductGiftSQL);
$this->view->listProductGift = $listProductGift;
$listCmdGiftSQL = "
SELECT pg.CMDMONTANT CMDMONTANT, pg.CMDPRODREFGIFT CMDPRODREFGIFT,pg.ID ID, pc.IDPRODUCT
FROM promo_gift AS pg
LEFT JOIN productchild AS pc ON pc.REFERENCE = pg.CMDPRODREFGIFT
WHERE pg.CMDMONTANT IS NOT NULL
AND pg.CMDPRODREFGIFT IS NOT NULL
ORDER BY pg.CMDPRODREFGIFT ASC";
$listCmdGift = $promoGift->getAdapter()->fetchAll($listCmdGiftSQL);
$this->view->listCmdGift = $listCmdGift;
}
function giftaddAction() {
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$params = $this->getRequest()->getPost();
$promoGift = new PromoGift();
$productChild = new ProductChild();
switch ($params['gift']) {
case 1 :
$buy = $filter->filter($params['referencebuy']);
$nbbuy = $filter->filter((int)$params['referencenbbuy']);
$gift = $filter->filter($params['referencegift']);
$nbgift = $filter->filter((int)$params['referencenbgift']);
if ($validator->isValid($buy) &&
$validator->isValid($gift) &&
((int)$nbbuy>0) &&
((int)$nbgift>0) ) {
$isExistBuy = $productChild->fetchRow("REFERENCE = '".$buy."' ");
if ($isExistBuy) {
$isExistGift = $productChild->fetchRow("REFERENCE = '".$gift."' ");
if ($isExistGift) {
$isExistPromo = $promoGift->fetchRow("PRODREFBUY = '".$buy."' AND PRODREFGIFT = '".$gift."'");
if (!$isExistPromo) {
$date = new Zend_Date();
$data = array (
'DATEINSERTGIFT' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'PRODREFBUY' => $buy,
'PRODREFGIFT' => $gift,
'PRODNBGIFT' => $nbgift,
'PRODNBBUY' => $nbbuy
);
$promoGift->insert($data);
$this->view->messageSuccess = "L'avantage est maintenant disponible";
} else {
$this->view->messageError = "L'avantage existe d�j�";
}
} else {
$this->view->messageError = "La r�f�rence ".$params['referencegift']." n'existe pas";
}
} else {
$this->view->messageError = "La r�f�rence ".$params['referencebuy']." n'existe pas";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
break;
case 2 :
$reference = $filter->filter($params['reference']);
if ($validator->isValid($params['montant']) &&
$validator->isValid($reference)) {
if ((int)$params['montant'] > 0) {
$isExistGift = $productChild->fetchRow("REFERENCE = '".$reference."' ");
if ($isExistGift) {
$isExistPromo = $promoGift->fetchRow("CMDMONTANT = '".$params['montant']."' AND CMDPRODREFGIFT = '".$reference."'");
if (!$isExistPromo) {
$date = new Zend_Date();
$data = array (
'DATEINSERTGIFT' => $date->toString('YYYY-MM-dd HH-mm-ss'),
'CMDMONTANT' => $filter->filter($params['montant']),
'CMDPRODREFGIFT' => $reference
);
$promoGift->insert($data);
$this->view->messageSuccess = "L'avantage est maintenant disponible";
} else {
$this->view->messageError = "L'avantage existe d�j�";
}
} else {
$this->view->messageError = "La r�f�rence ".$reference." n'existe pas";
}
} else {
$this->view->messageError = "Le montant doit etre > 0";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
break;
}
}
$this->_forward('gift');
}
function giftdelAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$promoGift = new PromoGift();
$promoGift->delete('ID = '.$id);
$this->view->messageSuccess = "L'avantage a �t� supprim�e ";
} else {
$this->view->messageError = "L'avantage n'a pas �t� supprim�e ";
}
}
$this->_forward('gift');
}
function codereductionAction(){
$this->view->titlePage = "Les Codes de r�duction";
$codeReduction = new CodeReduction();
$listCodes = $codeReduction->getAllCodes();
$this->view->listReduc = $listCodes;
}
private function passgen() {
$chaine ="mnoTUzS5678kVvwxy9WXYZRNCDEFrslq41GtuaHIJKpOPQA23LcdefghiBMbj0";
srand((double)microtime()*1000000);
for($i=0; $i<8; $i++){
@$pass .= $chaine[rand()%strlen($chaine)];
}
return $pass;
}
function addcodereductionproduitAction(){
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$params = array();
$params = $this->getRequest()->getPost();
$codereduc_euro = $params['codereduc_euro'];
$codereduc_pour = (int)$params['codereduc_pour'];
$isOK = true;
if ($codereduc_euro > 0 && $codereduc_pour > 0) {
$this->view->messageError = "La r�duction est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($codereduc_euro == 0 && $codereduc_pour == 0) {
$this->view->messageError = "La r�duction est soit en EURO, soit en POURCENTAGE et est obligatoire. ";
$isOK = false;
}
$codereduc_ref = $params['codereduc_ref'];
$codereduc_nbr = (int)$params['codereduc_nbr'];
$sd = $params['sd2'];
$ed = $params['ed2'];
if (($validator->isValid($codereduc_euro) ||
$validator->isValid($codereduc_pour)) &&
$isOK == true &&
$validator->isValid($codereduc_ref) &&
$validator->isValid($codereduc_nbr)
) {
$validator2 = new Zend_Validate();
$validator2->addValidator(new Zend_Validate_Date());
if ($validator2->isValid($sd) &&
$validator2->isValid($ed)
) {
$code = $this->passgen();
$labelProd = "produit";
$labelDroit = "donne";
if ($codereduc_nbr > 1) { $labelProd .= "s"; $labelDroit .= "nt"; }
$labelPrix = "";
if ($codereduc_pour > 0) { $labelPrix = $codereduc_pour. " %";
} else { $labelPrix = $codereduc_euro. " euros"; }
$libelle = $codereduc_nbr." ".$labelProd." de la r�ference : ".$codereduc_ref." ".$labelDroit." droit � ".$labelPrix." de r�duction. ";
$codeReduction = new CodeReduction();
$data = array(
"CODE" => $code,
"LIBELLE" => $libelle,
"PRODUITREF" => $codereduc_ref,
"PRODUITNBR" => $codereduc_nbr,
"EURO" => $codereduc_euro,
"POUR" => $codereduc_pour,
"DATESTART" => $sd,
"DATEEND" => $ed,
"isACTIF" => 1
);
$codeReduction->insert($data);
$this->view->messageSuccess = "CODE : ".$code." : ".$libelle;
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('codereduction');
}
function addcodereductioncommandeAction(){
if ($this->getRequest()->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$params = array();
$params = $this->getRequest()->getPost();
$codereduc_euro = $params['codereduc_euro'];
$codereduc_pour = (int)$params['codereduc_pour'];
$isOK = true;
if ($codereduc_euro > 0 && $codereduc_pour > 0) {
$this->view->messageError = "La r�duction est soit en EURO, soit en POURCENTAGE. ";
$isOK = false;
}
if ($codereduc_euro == 0 && $codereduc_pour == 0) {
$this->view->messageError = "La r�duction est soit en EURO, soit en POURCENTAGE et est obligatoire. ";
$isOK = false;
}
$codereduc_cmdmin = $params['codereduc_cmdmin'];
$sd = $params['sd1'];
$ed = $params['ed1'];
if (($validator->isValid($codereduc_euro) ||
$validator->isValid($codereduc_pour)) &&
$isOK == true &&
$validator->isValid($codereduc_cmdmin)
) {
$validator2 = new Zend_Validate();
$validator2->addValidator(new Zend_Validate_Date());
if ($validator2->isValid($sd) &&
$validator2->isValid($ed)
) {
if ($codereduc_cmdmin > 0) {
$code = $this->passgen();
$labelPrix = "";
if ($codereduc_pour > 0) { $labelPrix = $codereduc_pour. " %";
} else { $labelPrix = $codereduc_euro. " euros"; }
$libelle = "Pour ".$codereduc_cmdmin." euros de commande, il y a ".$labelPrix." de r�duction. ";
$codeReduction = new CodeReduction();
$data = array(
"CODE" => $code,
"LIBELLE" => $libelle,
"CMDTOTAL" => $codereduc_cmdmin,
"EURO" => $codereduc_euro,
"POUR" => $codereduc_pour,
"DATESTART" => $sd,
"DATEEND" => $ed,
"isACTIF" => 1
);
$codeReduction->insert($data);
$this->view->messageSuccess = "CODE : ".$code."<br/> ".$libelle;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('codereduction');
}
function delcodereductionAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$codeReduction = new CodeReduction();
$codeReduction->delete('ID = '.$id);
$this->view->messageSuccess = "Le code de r�duction a �t� supprim�e ";
} else {
$this->view->messageError = "Le code de r�duction n'a pas �t� supprim�e ";
}
}
$this->_forward('codereduction');
}
function activecodereductionAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$codeReduction = new CodeReduction();
$data = array(
"isACTIF" => 1
);
$codeReduction->update($data,'ID = '.$id);
$this->view->messageSuccess = "Le code de r�duction est actif ";
}
}
$this->_forward('codereduction');
}
function unactivecodereductionAction() {
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id > 0 ) {
$codeReduction = new CodeReduction();
$data = array(
"isACTIF" => 0
);
$codeReduction->update($data,'ID = '.$id);
$this->view->messageSuccess = "Le code de r�duction est inactif ";
}
}
$this->_forward('codereduction');
}
}
?>PK �0H[;z�8O O AnnonceleftController.phpnu &1i� <?php
class Backoffice_AnnonceleftController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "AnnonceLeft";
$this->isConnectedWithRole('isPromo');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier une Annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$annonce = new AnnonceLeft();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonceLeft = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow'],
'ID_CATS' => ''
);
if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}
if ($validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT'])&&
!empty($dataAnnonce['ID_CATS'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "La publicit� a �t� modifi�e";
$this->view->populateFormAnnonceLeft = $annonce->fetchRow('ID = '.$id);
$this->log("La publicit� a �t� modifi�e ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceLeft = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceLeft = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function addAction()
{
$this->view->titlePage = "Ajouter une Annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow'],
'ID_CATS' => ''
);
if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}
if (
$validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT']) &&
!empty($dataAnnonce['ID_CATS'])
) {
try {
$annonce = new AnnonceLeft();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "La publicit� a �t� ajout�e";
$this->log("La publicit� a �t� ajout�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonceLeft = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonceLeft = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function listAction()
{
$this->view->titlePage = "Gestion des publicit�s par cat�gories";
//Appel model pour listing
$annonces = new AnnonceLeft();
$result = $annonces->getAllAnnonces();
$category = new Category();
$this->view->listallcategories = $category->getAllCategoriesByID(0);
$this->view->listannonceleft = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceLeft();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "La publicit� a �t� supprim�e";
$this->log("La publicit� a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[+i��rj rj PrestashopController.phpnu &1i� <?php
class Backoffice_PrestashopController extends Modules_Backoffice_Controllers_MainController {
function init() {
$this->view->title = "Administration";
$this->view->currentMenu = "Prestashop";
$this->isConnectedWithRole ( 'isMaintenance' );
}
public function indexAction() {
$this->view->titlePage = "Gestion commerciale Prestashop";
$this->view->messageSuccess = "";
$this->view->messageError = "";
}
private $_SEPARATOR = ';';
private function cleanUp($value) {
$result = $value;
$filter = new Zend_Filter ();
$filter->addFilter ( new Zend_Filter_StringTrim () )->addFilter ( new Zend_Filter_StripTags () );
$result = $filter->filter ( $result );
$result = html_entity_decode ( $result, ENT_QUOTES, "ISO-8859-1" );
$result = str_replace ( "\r\n", "", $result );
$result = str_replace ( '�', " ", $result );
$result = str_replace ( '"', '\"', $result );
$result = str_replace ( $this->_SEPARATOR, "", $result );
return !empty($result) ? '"'.$result.'"' : "";
}
private function cleanUpSpace($value) {
$filter = new Zend_Filter ();
$filter->addFilter ( new Zend_Filter_Alnum () );
$value = str_replace ( $this->_SEPARATOR, "", $value );
return $filter->filter ( $value );
}
private function cleanUpAddQuote($value) {
return '"' . $this->cleanUp ( $value ) . '"';
}
function exportclientsAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel ();
$user = new User ();
$select = $user->select ()->order ( "ID ASC" );
$listusers = $user->fetchAll ( $select );
foreach ( $listusers as $row ) {
$result = $row ['ID'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code Famille
// Facturation
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->cleanUpSpace ( $row ['CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['VILLE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['DEPARTEMENT'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['FONCTION'] ) . $this->_SEPARATOR;
$result .= $row ['TEL'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $row ['FAX'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['EMAIL'] ) . $this->_SEPARATOR;
// Livraison
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Adresse 2
$result .= $this->_SEPARATOR; // Adresse 3
$result .= $this->_SEPARATOR; // Adresse 4
$result .= $this->cleanUpSpace ( $row ['CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['VILLE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['DEPARTEMENT'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Site Web
// Contact
$result .= $row ['CIVILITE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['FONCTION'] ) . $this->_SEPARATOR;
$result .= $row ['TEL'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Tel Portable
$result .= $row ['FAX'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['EMAIL'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Compte comptable
$result .= $this->cleanUpSpace ( $row ['NUMIDFISC'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpSpace ( $row ['SIRET'] ) . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code NAF
$result .= "0";
$fichier->Insertion ( $result );
}
$fichier->output ( 'ebp_clients' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
function exportfournisseursAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : Prestashop";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel ();
$supplier = new Supplier ();
$select = $supplier->select ()->order ( "ID ASC" );
$listsuppliers = $supplier->fetchAll ( $select );
$supplierBrend = new SupplierBrend ();
$result = "ID" . $this->_SEPARATOR;
$result .= "Active (0/1)" . $this->_SEPARATOR;
$result .= "Name *".$this->_SEPARATOR;
$result .= "Description".$this->_SEPARATOR;
$result .= "Short description".$this->_SEPARATOR;
$result .= "Meta title".$this->_SEPARATOR;
$result .= "Meta keywords".$this->_SEPARATOR;
$result .= "Meta description".$this->_SEPARATOR;
$result .= "Image URL";
$fichier->Insertion ($result);
foreach ( $listsuppliers as $row ) {
$listbrends = $supplierBrend->select()->where ( "IDSUPPLIER = " . $row ['ID'] )->query ()->fetchAll ();
foreach ( $listbrends as $rowBrend ) {
$result = $rowBrend['ID'].$this->_SEPARATOR;
$result .= '1'. $this->_SEPARATOR;
$result .= $this->cleanUp ( $rowBrend ['BREND'] ) . $this->_SEPARATOR;
$result .= '"'.str_replace ( '"', '\"',$row ['DESCRIPTIONLONG'] ).'"'.$this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['DESCRIPTIONSHORT'] ).$this->_SEPARATOR;
$result .= $this->cleanUp ( $rowBrend ['BREND']." - Achat / Vente produits ".$rowBrend ['BREND']." pour professionnel").$this->_SEPARATOR;
$result .= $this->cleanUp ( $rowBrend ['BREND'].", ".$row ['COMPANY']).$this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['DESCRIPTIONSHORT'] ).$this->_SEPARATOR;
$result .=$this->baseUrl_SiteCommerceUrl."/".$rowBrend ['URL'];
$fichier->Insertion ( $result );
}
}
$fichier->output ( 'presta_fabricants' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
function exportcategoriesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : Prestashop";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//Prestashop
$result = "ID". $this->_SEPARATOR;
$result .= "Active (0/1)" . $this->_SEPARATOR;
$result .= "Name *". $this->_SEPARATOR;
$result .= "Parent category".$this->_SEPARATOR;
$result .= "Root category (0/1)".$this->_SEPARATOR;
$result .= "Description".$this->_SEPARATOR;
$result .= "Meta title". $this->_SEPARATOR;
$result .= "Meta keywords". $this->_SEPARATOR;
$result .= "Meta description". $this->_SEPARATOR;
$result .= "URL rewritten".$this->_SEPARATOR;
$result .= "Image URL";
$fichier = new FichierExcel ();
$fichier->Insertion ( $result );
$category = new Category ();
$sql = "SELECT c.* FROM category AS c where idparent = 0 order by ID asc";
$listcategories =$category->getAdapter ()->fetchAll($sql);
$this->exportcategoriescsvline($fichier, $listcategories, "Accueil");
$fichier->output ( 'presta_categories' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
private function exportcategoriescsvline($fichier, $listcategories, $parentName) {
$category = new Category ();
foreach ( $listcategories as $row ) {
$isroot = '0';
$id = "";//$row ['ID'];
$result = $id. $this->_SEPARATOR;
$result .= $row ['isACTIVE'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $parentName .$this->_SEPARATOR;
$result .= $isroot.$this->_SEPARATOR;
$name = !empty($row['DESCRIPTIONLONG']) ? $row ['DESCRIPTIONLONG'] : $row ['DESCRIPTION'];
$result .= '"'.str_replace ( '"', '\"',$name).'"'.$this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NAVTITRENOM'] ). $this->_SEPARATOR;
$result .= '"'.str_replace ( '"', '\"',substr($row ['KEYWORDS'], 0, 255)).'"'. $this->_SEPARATOR;
$result .= '"'.str_replace ( '"', '\"',substr($row ['NAVDESCRIPTION'], 0, 255)).'"'. $this->_SEPARATOR;
$result .= $this->_SEPARATOR;
$result .= $this->baseUrl_SiteCommerceUrl."/".$row ['URL'];
$fichier->Insertion ( $result );
$sql = "SELECT c.* FROM category AS c where idparent = ".$row ['ID']." order by NOM asc";
$listcategoriesubs =$category->getAdapter ()->fetchAll($sql);
if (!empty($listcategoriesubs)) {
$this->exportcategoriescsvline($fichier, $listcategoriesubs, $this->cleanUp ( $row ['NOM'] ));
}
}
}
private function getUrlPage($params) {
return $this->baseUrl_SiteCommerceUrl . "/" . $params ['PAGE'] . "-" . $params ['ID'] . ".html";
}
function exportarticlesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : Prestashop";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$fichier = new FichierExcel ();
$sql = "SELECT p.ID ID, p.NOM NOM,p.NAVNOM NAVNOM, p.DESCRIPTIONSHORT DESCSHORT, p.DESCRIPTIONLONG DESCLONG, p.PRIX PRIX, p.isDEVIS isDEVISPRODUCT,
p.DOCNAME DOCNAME, p.DOCURL DOCURL, p.IDBREND IDBREND,
p.isPROMO isPROMO, pic.URL URLIMAGE, sb.BREND BREND, sb.URL BRENDURL, p.IDCATEGORY IDCATEGORY, c.NOM CATEGORYNOM,
p.DESCRIPTIONTECH DESCTECH, p.DESCRIPTIONNORME DESCNORME
FROM product p
LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID
LEFT JOIN supplier_brend sb ON sb.ID = p.IDBREND
LEFT JOIN category AS c ON c.ID = p.IDCATEGORY
WHERE p.isACTIVE = 0
AND pic.POSITION = 1
GROUP BY ID
ORDER BY p.ID ASC";
$product = new Product ();
$productChild = new ProductChild ();
$listProducts = $product->getAdapter ()->fetchAll ( $sql );
foreach ( $listProducts as $row ) {
$sqlChild = "
SELECT pc.ID ID ,pc.REFERENCE REFERENCE,pc.DESIGNATION DESIGNATION,pc.PRIX PRIX, pc.isPROMO isPROMO ,
pc.IMAGEPROMO IMAGEPROMO,pc.isDEVIS isDEVIS, pc.QUANTITYMIN QUANTITYMIN
FROM productchild AS pc
WHERE pc.IDPRODUCT = " . $row ['ID'] . "
ORDER BY pc.PRIX ASC";
$productChildTemp = $productChild->getAdapter ()->fetchAll ( $sqlChild );
$navnom = $this->verifyNavigationString ( $row ['NAVNOM'], $row ['NOM'], '' );
$urlImage = $this->baseUrl_SiteCommerceUrl . "/" . $row ['URLIMAGE'];
$urlPage = $this->getUrlPage ( array (
'PAGE' => $navnom,
'ID' => $row ['ID']
) );
$fraislivraison = "";
$garantie = "";
$reference = "";
$description = "";
foreach ( $productChildTemp as $rowChild ) {
$reference = $this->cleanUp ( $rowChild ['REFERENCE'] );
$description = $this->cleanUp ( $rowChild ['DESIGNATION'] );
$result = $rowChild ['ID'] . $this->_SEPARATOR;
$result .= $this->cleanUp ( $row ['NOM'] ) . $this->_SEPARATOR;
$result .= $row ['IDCATEGORY'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Prix de revient
$result .= $rowChild ['PRIX'] . $this->_SEPARATOR;
$result .= $this->tva . $this->_SEPARATOR;
$result .= $description . $this->_SEPARATOR;
$result .= $reference . $this->_SEPARATOR; // Code barre
$result .= $this->_SEPARATOR; // Code unite
$result .= $this->_SEPARATOR; // Type d'article
$result .= $this->_SEPARATOR; // Code emplacement
$result .= $row ['IDBREND'] . $this->_SEPARATOR;
$result .= $this->_SEPARATOR; // Code �co
$fichier->Insertion ( $result );
}
}
$fichier->output ( 'ebp_articles' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
private function formatDate($datevalue) {
$date = new Zend_Date ();
$date->set ( $datevalue );
return $date->toString ( 'dd/MM/YYYY' );
}
private function getCommandDevisLine($listcommands) {
$commandLine = new CommandProduct ();
$fichier = new FichierExcel ();
$result = "Document - Num�ro du document;Document - Date;Document - Code client;Document - Nom du client;Document - Adresse 1 (facturation);Document - Code postal (facturation);Document - Ville (facturation);Document - Code Pays (facturation);Document - Nom (contact) (facturation);Document - Pr�nom (facturation);Document - T�l�phone fixe (facturation);Document - Fax (facturation);Document - E-mail (facturation);Document - Nom (adresse) (livraison);Document - Adresse 1 (livraison);Document - Code postal (livraison);Document - Ville (livraison);Document - Code Pays (livraison);Document - T�l�phone fixe (livraison);Document - Fax (livraison);Document - E-mail (livraison);Document - Frais de port HT;Document - Total Brut HT;Document - Total TTC;Document - Taux de TVA port;Ligne - Code article;Ligne - Quantit�;Ligne - Taux de TVA;Ligne - PV HT;Ligne - Montant Net HT;Ligne - Montant de remise unitaire HT cumul�";
$fichier->Colonne ( $result );
foreach ( $listcommands as $row ) {
$result = '"' . $row ['REFERENCE'] . '"' . $this->_SEPARATOR;
$result .= '"' . $this->formatDate ( $row ['DATESTART'] ) . '"' . $this->_SEPARATOR;
$result .= '"' . $row ['IDUSER'] . '"' . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['FACT_ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['FACT_CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['FACT_VILLE'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_NOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_PRENOM'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_TEL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_FAX'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_EMAIL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_RAISONSOCIAL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_ADRESSE'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_CP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['LIV_VILLE'] ) . $this->_SEPARATOR;
$result .= "FR" . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_TEL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_FAX'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['USER_EMAIL'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['PRIXFRAISPORT'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['PRIXTOTALHTFP'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $row ['PRIXTOTALTTC'] ) . $this->_SEPARATOR;
$result .= $this->cleanUpAddQuote ( $this->getCurrentTva ( $row ['DATESTART'] ) ) . $this->_SEPARATOR;
$selectLine = $commandLine->select ()->where ( "IDCOMMAND = " . $row ["ID"] );
$listLines = $commandLine->fetchAll ( $selectLine );
foreach ( $listLines as $rowLine ) {
$resultLine = $result;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDID'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDQUANTITY'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $this->getCurrentTva ( $row ['DATESTART'] ) ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDPRIX'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDPRIXTOTAL'] ) . $this->_SEPARATOR;
$resultLine .= $this->cleanUpAddQuote ( $rowLine ['CHILDPRIXREMISE'] ) . $this->_SEPARATOR;
$fichier->Insertion ( $resultLine );
}
}
return $fichier;
}
function exportcommandesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$command = new Command ();
$date = new Zend_Date ();
$date->addMonth ( - 3 );
$select = "
SELECT *
FROM command
WHERE isARCHIVE = 1
AND STATUT IN (1, 2, 3)
AND DATESTART >= '" . $date->toString ( 'YYYY-MM-dd' ) . "'";
$listcommands = $command->getAdapter ()->fetchAll ( $select );
$fichier = $this->getCommandDevisLine ( $listcommands );
$fichier->output ( 'ebp_commandes' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
function exportdevisAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$command = new Command ();
$date = new Zend_Date ();
$date->addMonth ( - 3 );
$select = "
SELECT *
FROM command
WHERE isARCHIVE = 1
AND STATUT IN (10, 11)
AND DATESTART >= '" . $date->toString ( 'YYYY-MM-dd' ) . "'";
$listcommands = $command->getAdapter ()->fetchAll ( $select );
$fichier = $this->getCommandDevisLine ( $listcommands );
$fichier->output ( 'ebp_devis' );
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
}
function importcategoriesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$nomTemp = 'csvfile';
if ($this->isValidCSVFile ( $nomTemp )) {
$nomOrigine = $_FILES [$nomTemp] ['name'];
$date = new Zend_Date ();
$nomDestination = "importcategories-" . $date->toString ( 'dd-MM-YYYY_HH-mm-ss' ) . ".csv";
if ($this->uploadCsvFile ( $_FILES [$nomTemp] ["tmp_name"], $nomDestination )) {
$header = array (
0 => 'ID',
1 => 'NOM',
2 => 'NOUSE1',
3 => 'NOUSE2',
4 => 'NOUSE3',
5 => 'NOUSE4',
6 => 'NOUSE5',
7 => 'NOUSE6'
);
$dataRows = $this->csv_to_array ( $this->csv_import . $nomDestination, $header );
if (sizeof ( $dataRows [0] ) == sizeof ( $header )) {
$category = new Category ();
$filesAdded = 0;
$filesUpdated = 0;
$filesError = 0;
foreach ( $dataRows as $row ) {
$id = $row ["ID"];
$nom = $this->cleanUp ( $row ["NOM"] );
$currentCat = $category->select ()->where ( "ID = ?", $id )->query ()->fetch ();
if ($currentCat != null && ! empty ( $currentCat )) {
try {
// Update
if ($currentCat ['NOM'] != $nom) {
$data = array (
'NOM' => $nom
);
$category->update ( $data, 'ID = ' . $id );
$filesUpdated ++;
}
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
} else {
try {
$navnom = $this->verifyNavigationString ( "", $nom, '' );
$keywords = $this->generateKeyWords ( $navnom );
// Insert
$data = array (
'NOM' => $nom,
'NAVTITRENOM' => $nom,
'DESCRIPTION' => $nom,
'NAVDESCRIPTION' => $nom,
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'IDPARENT' => 0
);
$category->insert ( $data );
$lastid = $category->getAdapter()->lastInsertId();
if ($lastid > 0) {
mkdir ("items/category/".$lastid, 0777);
mkdir ("items/product/".$lastid, 0777);
}
$filesAdded ++;
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
}
}
$this->view->messageSuccess = "Importation des fiches Familles articles<br/>
Fiches ajout�es : " . $filesAdded . "<br/>
Fiches modifi�es : " . $filesUpdated . "<br/>
Fiches non import�es : " . $filesError . "<br/>";
} else {
$this->view->messageError = "Le fichier n'est pas au format attendu pour les Familles articles";
}
} else {
$this->view->messageError = "Le fichier n'a pas pu etre import�.";
}
}
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
$this->render ( '/index' );
}
function importarticlesAction() {
try {
$this->_helper->viewRenderer->setNeverRender ();
$this->view->titlePage = "Gestion commerciale : EBP";
$this->view->messageSuccess = "";
$this->view->messageError = "";
$nomTemp = 'csvfile';
if ($this->isValidCSVFile ( $nomTemp )) {
$nomOrigine = $_FILES [$nomTemp] ['name'];
$date = new Zend_Date ();
$nomDestination = "importarticles-" . $date->toString ( 'dd-MM-YYYY_HH-mm-ss' ) . ".csv";
if ($this->uploadCsvFile ( $_FILES [$nomTemp] ["tmp_name"], $nomDestination )) {
$header = array (
0 => 'ID',
1 => 'NOM',
2 => 'IDCATEGORY',
3 => 'NOUSE1',
4 => 'PRIX',
5 => 'TVA',
6 => 'DESCRIPTION',
7 => 'REFERENCE',
8 => 'NOUSE2',
9 => 'NOUSE3',
10 => 'NOUSE4',
11 => 'IDBREND',
12 => 'NOUSE5'
);
$dataRows = $this->csv_to_array ( $this->csv_import . $nomDestination, $header );
if (sizeof ( $dataRows [0] ) == sizeof ( $header )) {
$product = new Product ();
$productLine = new ProductChild ();
$filesAdded = 0;
$filesUpdated = 0;
$filesError = 0;
$date = new Zend_Date ();
foreach ( $dataRows as $row ) {
$id = $row ["ID"];
$prix = $this->cleanUp ( $row ["PRIX"] );
$description = $this->cleanUp ( $row ["DESCRIPTION"] );
$reference = $this->cleanUp ( $row ["REFERENCE"] );
$tva = $this->cleanUp ( $row ["TVA"] );
$nom_prod = $this->cleanUp ( $row ["NOM"] );
$idCat_prod = $this->cleanUp ( $row ["IDCATEGORY"] );
$idbrend_prod = $this->cleanUp ( $row ["IDBREND"] );
$currentProdLine = $productLine->select ()->where ( "REFERENCE = ?", $reference )->query ()->fetch ();
if ($currentProdLine != null && ! empty ( $currentProdLine )) {
try {
// Update
$dataChild = array (
'DESIGNATION' => $description,
'PRIX' => $prix,
'DATEMODIF' => $date->toString ( 'YYYY-MM-dd HH:mm:ss' )
);
$productChild = new ProductChild ();
$productChild->update ( $dataChild, 'ID = ' . $id );
$filesUpdated ++;
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
} else {
try {
// Insert
$navnom = $this->verifyNavigationString ( "", $nom_prod, '' );
$keywords = $this->generateKeyWords ( $navnom );
$data = array (
'NOM' => $nom_prod,
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'NAVTITRE' => '',
'NAVDESC' => '',
'DESCRIPTIONSHORT' => $nom_prod,
'DESCRIPTIONLONG' => $nom_prod,
'PRIX' => $prix,
'isACTIVE' => 1,
'DATEPROMO' => $date->toString ( 'YYYY-MM-dd' ),
'isPROMO' => '1',
'IDCATEGORY' => $idCat_prod,
'ISSHOWBREND' => 1
);
$product->insert ( $data );
$lastId = $product->getAdapter ()->lastInsertId ();
$dataChild = array (
'REFERENCE' => $reference,
'DESIGNATION' => $description,
'PRIX' => $prix,
'ETATSTOCK' => 0,
'QUANTITYMIN' => 1,
'isDEVIS' => 1,
'IMAGEPROMO' => 0,
'DATEMODIF' => $date->toString ( 'YYYY-MM-dd HH:mm:ss' ),
'IDPRODUCT' => $lastId
);
$productChild = new ProductChild ();
$productChild->insert ( $dataChild );
$filesAdded ++;
} catch ( Zend_Exception $e ) {
$filesError ++;
$this->log ( $e->getMessage (), 'warn' );
}
}
}
$this->view->messageSuccess = "Importation des fiches Articles<br/>
Fiches ajout�es : " . $filesAdded . "<br/>
Fiches modifi�es : " . $filesUpdated . "<br/>
Fiches non import�es : " . $filesError . "<br/>";
} else {
$this->view->messageError = "Le fichier n'est pas au format attendu pour les Articles";
}
} else {
$this->view->messageError = "Le fichier n'a pas pu etre import�.";
}
}
} catch ( Zend_Exception $e ) {
$this->log ( $e->getMessage (), 'err' );
}
$this->render ( '/index' );
}
var $csv_import = 'csvfiles/import/';
private function uploadCsvFile($tmpName, $destName) {
if (! file_exists ( $this->csv_import )) {
mkdir ( $this->csv_import, 0777, true );
}
return move_uploaded_file ( $tmpName, $this->csv_import . $destName );
}
private function isValidCSVFile($name) {
if (! empty ( $_FILES [$name] ) && ! empty ( $_FILES [$name] ['name'] )) {
$nomOrigine = $_FILES [$name] ['name'];
$elementsChemin = pathinfo ( $nomOrigine );
$extensionFichier = strtolower($elementsChemin ['extension']);
$extensionsAutorisees = array (
"csv"
);
if (! (in_array ( $extensionFichier, $extensionsAutorisees ))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue (.csv)";
} else {
return true;
}
} else {
$this->view->messageError = "Vous pouvez exporter les donn�es via EBP -> Outils -> Exportation de donn�es";
}
return false;
}
private function csv_to_array($filename = '', $header, $delimiter = ';') {
if (! file_exists ( $filename ) || ! is_readable ( $filename ))
return FALSE;
$data = array ();
if (($handle = fopen ( $filename, 'r' )) !== FALSE) {
while ( ($row = fgetcsv ( $handle, 1000, $delimiter )) !== FALSE ) {
if (! $header) {
$header = $row;
} else if (sizeof ( $header ) == sizeof ( $row )) {
$data [] = array_combine ( $header, $row );
}
}
fclose ( $handle );
}
return $data;
}
}
?>PK �0H[�(X( ( FooterController.phpnu &1i� <?php
class Backoffice_FooterController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Footer";
$this->isConnectedWithRole('isFooter');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier un pied de page";
$this->view->messageSuccess = "";
$this->view->messageError = "";
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
$footer = new FooterContent();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormFooter = $footer->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataFooter = array (
'ID' => (int)$params['id'],
'TITRE' => $filter->filter($params['titre']),
'URL' => $filter->filter($params['url']),
'CONTENT' => $params['content']
);
if ($validator->isValid($dataFooter['TITRE'])
) {
if ((empty($dataFooter['URL']) && empty($dataFooter['CONTENT'])) ||
(!empty($dataFooter['URL']) && !empty($dataFooter['CONTENT']))
) {
$this->view->messageError = "Le pied de page est soit un lien vers une autre page, soit du contenu";
$this->view->populateFormFooter = $dataFooter;
} else {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$footer->update($dataFooter,'ID = '.$id);
$this->view->messageSuccess = "Le pied de page a �t� modifi�";
$this->view->populateFormFooter = $footer->fetchRow('ID = '.$id);
$this->log("Le pied de page a �t� modifi� : ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormFooter = $dataFooter;
}
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormFooter = $dataFooter;
}
}
}
public function addAction()
{
$this->view->titlePage = "Ajouter un pied de page";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataFooter = array (
'TITRE' => $filter->filter($params['titre']),
'URL' => $filter->filter($params['url']),
'CONTENT' => $params['content']
);
if (
$validator->isValid($dataFooter['TITRE'])
) {
if ((empty($dataFooter['URL']) && empty($dataFooter['CONTENT'])) ||
(!empty($dataFooter['URL']) && !empty($dataFooter['CONTENT']))
) {
$this->view->messageError = "Le pied de page est soit un lien vers une autre page, soit du contenu";
$this->view->populateFormFooter = $dataFooter;
} else {
try {
$footer = new FooterContent();
$footer->insert($dataFooter);
$this->view->messageSuccess = "Le pied de page a �t� ajout�";
$this->log("Le pied de page a �t� ajout�",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormFooter = $dataFooter;
}
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
$this->view->populateFormFooter = $dataFooter;
}
}
}
public function listAction()
{
$this->view->titlePage = "Gestion des pieds de page";
//Appel model pour listing
$footer = new FooterContent();
$result = $footer->fetchAll();
$this->view->listfooter = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$footer = new FooterContent();
$footer->delete('ID = '.$id);
$this->view->messageSuccess = "Le pied de page a �t� supprim�";
$this->log("Le pied de page a �t� supprim�",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
public function docAction() {
$this->view->titlePage = "Gestion des documents";
$this->view->currentMenu = "Document";
}
public function adddocAction() {
if(!empty($_FILES['file']) && !empty($_FILES['file']['name'])) {
$nomOrigine = $_FILES['file']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("pdf");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
$repertoireDestination = 'doc/';
$this->checkDirectoryExist($repertoireDestination);
//$date = new Zend_Date();
$nomDestination = $nomOrigine;//$date->toString('dd-MM-YYYY_HH-mm-ss').".".$extensionFichier;
if (move_uploaded_file($_FILES["file"]["tmp_name"],$repertoireDestination.$nomDestination)) {
try {
$this->view->messageSuccess = "Le document a �t� ajout� ";
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
}
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
} else {
$this->view->messageError = "S�lectionner un fichier PDF";
}
$this->_forward('doc');
}
public function deldocAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
unlink($params['doc']);
$this->view->messageSuccess = "Le document a �t� supprim� d�finitivement";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('doc');
}
}
?>PK �0H[x`ޱ� � AnnoncerightController.phpnu &1i� <?php
class Backoffice_AnnoncerightController extends Modules_Backoffice_Controllers_MainController
{
public function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "AnnonceRight";
$this->isConnectedWithRole('isPromo');
}
public function indexAction()
{
$this->_forward('/list');
}
public function editAction()
{
$this->view->titlePage = "Modifier une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
try {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
$annonce = new AnnonceRight();
if ($this->getRequest()->getParam('id')) {
$id = (int)$this->getRequest()->getParam('id');
if ($id>0) {
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
}
}
if ($this->getRequest()->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'ID' => (int)$params['id'],
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow'],
'POSITION' => $params['position'],
'ID_CATS' => ''
);
/*if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}*/
if ($validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$id = (int)$params['id'];
if ( $id > 0) {
$annonce->update($dataAnnonce,'ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� modifi�e";
$this->view->populateFormAnnonce = $annonce->fetchRow('ID = '.$id);
$this->log("L'annonce a �t� modifi�e ".$id,'info');
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonce = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
} catch (Zend_Exception $e) {
$this->log("Error edit : ".$e->getMessage(),'err');
}
$this->_forward('/list');
}
public function addAction()
{
$this->view->titlePage = "Ajouter une annonce";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty())
-> addValidator(new Zend_Validate_StringLength(3));
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$dataAnnonce = array (
'NOM' => $filter->filter($params['nom']),
'CONTENT' => $params['content'],
'isSHOW' => $params['isshow'],
'POSITION' => $params['position'],
'ID_CATS' => ''
);
/*
if (isset($params['categories'])) {
foreach($params['categories'] as $value)
{
$dataAnnonce['ID_CATS'] .= ":".$value.":";
}
}*/
if (
$validator->isValid($dataAnnonce['NOM']) &&
$validator->isValid($dataAnnonce['CONTENT'])
) {
try {
$annonce = new AnnonceRight();
$annonce->insert($dataAnnonce);
$this->view->messageSuccess = "L'annonce a �t� ajout�e";
$this->log("L'annonce a �t� ajout�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->populateFormAnnonce = $dataAnnonce;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateFormAnnonce = $dataAnnonce;
}
}
$this->_forward('/list');
}
public function listAction()
{
$this->view->titlePage = "Gestion des mises en avant sur la page d'accueil";
//Appel model pour listing
$annonces = new AnnonceRight();
$result = $annonces->getAllAnnonces();
/*$category = new Category();
$this->view->listallcategories = $category->getAllCategoriesByID(0);
*/
$this->view->listannonce = $result;
}
public function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$annonce = new AnnonceRight();
$annonce->delete('ID = '.$id);
$this->view->messageSuccess = "L'annonce a �t� supprim�e";
$this->log("L'annonce a �t� supprim�e",'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
}
$this->_forward('/list');
}
}
?>PK �0H[����g �g CategoryController.phpnu &1i� <?php
class Backoffice_CategoryController extends Modules_Backoffice_Controllers_MainController
{
function init()
{
$this->view->title = "Administration";
$this->view->currentMenu = "Category";
$this->isConnectedWithRole('isCategory');
}
function indexAction()
{
$this->_forward('/list');
}
function listAction()
{
$this->view->titlePage = "Gestion des cat�gories";
//Gestion des tris
$table = 'NOM';
$tri = 'ASC';
}
function delAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id')) {
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
try {
$category = new Category();
if ($category->fetchRow('IDPARENT = '.$id)) {
$this->view->messageError = 'Cette cat�gorie est parente';
} else {
$product = new Product();
$select = $product->fetchRow('IDCATEGORY = '.$id);
if ($select) {
$this->view->messageError = 'Cette cat�gorie est utilis�e par le produit : <b>'.$select->NOM."<b/>";
} else {
$category->delete('ID = '.$id);
$this->delete_directory('items/category/'.$id);
$this->delete_directory('items/product/'.$id);
$this->view->messageSuccess = "La cat�gorie a et� supprim�e";
$this->log("La cat�gorie a et� supprim�e",'info');
}
}
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/list');
}
function editAction() {
$this->view->titlePage = "Modifier une cat�gorie";
//populate form
if ($this->_request->getParam('id')) { $id = (int)$this->_request->getParam('id'); }
if ($this->_request->getParam('idCat')) { $id = (int)$this->_request->getParam('idCat'); }
if ($id > 0) {
$category = new Category();
$row = $category->fetchRow('ID = '.$id);
if ($row) {
$this->view->populateForm = $row->toArray();
$listCat = array();
$listCat = $category->getTreeCatsOf($id);
if (!empty($listCat) && !$listCat['SUBS']) {
$categoryTypeTri = new CategoryTypeTri();
$this->view->listNavigationTri = $categoryTypeTri->getListTriByCategoryInOneRow($id);
}
if ($this->isSiteGallery) {
$annonces = new AnnonceCms();
$this->view->listAnnoncecms = $annonces->getAllAnnoncesByCategory($id);
$annonces = new AnnonceGallery();
$this->view->listAnnonceGallery = $annonces->getAllAnnoncesByCategory($id);
}
} else { $this->_forward('/list'); }
} else {
$this->_forward('/list');
}
}
function editmigrateAction()
{
$this->view->titlePage = "Modifier une cat�gorie";
if ($this->_request->isPost()) {
//get the form params
$params = $this->_request->getPost();
try {
$id = (int)$params['id'];
$idReceiver = (int)$params['idcategory'];
if ($id > 0 && $idReceiver > 0) {
$category = new Category();
if ($category->canBeMigrate($id)) {
//Migration des produits
$dataProduct = array (
'IDCATEGORY' => $idReceiver
);
$product = new Product();
$product->update($dataProduct, 'IDCATEGORY = '.$id);
$dataCategory = array (
'isACTIVE' => false
);
$category->update($dataCategory, 'ID = '.$id);
$this->view->messageSuccess .= "La cat�gorie a �t� migr�e, la redirection est effectu�e";
$this->log("La cat�gorie a �t� migr�e de ".$id." vers ".$idReceiver,'info');
} else {
$this->view->messageError .= "La cat�gorie est parente";
}
} else {
$this->view->messageError .= "V�rifier les param�tres";
}
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "Impossible de migrer la cat�gorie".$e->getMessage();
}
}
$this->_forward('/edit');
}
function editcategoryAction()
{
$this->view->titlePage = "Modifier une cat�gorie";
$id = 0;
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$docChoice = '';
if (isset($params['docChoice'])) {
$docChoice = $filter->filter($params['docChoice']);
}
$urlRedirect = '';
if (isset($params['urlredirect'])) {
$urlRedirect = $filter->filter($params['urlredirect']);
}
//Refractor the params
$data = array (
'NOM' => $filter->filter($params['nom']),
'IDPARENT' => $filter->filter($params['idparent']),
'DESCRIPTION' => $params['desc'],
'DESCRIPTIONLONG' => $params['desclong'],
'DESCRIPTIONSHORT' => $params['descshort'],
'URLREDIRECT' => $urlRedirect,
'CHOICEDOC' => $docChoice
);
if (isset($params['position'])) {
$data['POSITION'] = (int)$params['position'];
}
if ($validator->isValid($data['NOM'])) {
try {
$id = $params['id'];
$category = new Category();
$category->update($data, 'ID = '.$id);
$this->view->messageSuccess = "La cat�gorie a �t� modifi�e";
if($this->uploadNewPicsAndSave($id)) {
$this->view->messageSuccess .= " , l'image aussi";
}
if($this->uploadNewPicsSlideAndSave($id)) {
$this->view->messageSuccess .= " , l'image du slide aussi";
}
if($this->uploadNewChoicePics($id)) {
$this->view->messageSuccess .= " , le comment choisir aussi";
}
$nbSubs = $category->updateTreeInLineAsPathOfChilds($id, true);
$this->view->messageSuccess .= " , ".$nbSubs." urls d'acc�s modifi�es.";
$this->log("La cat�gorie a �t� modifi�e : ".$id,'info');
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La cat�gorie existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError = $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/edit');
}
function customnavnomeditAction()
{
$this->view->titlePage = "Modifier une cat�gorie";
$id = 0;
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$navnom = $this->verifyNavigationString($filter->filter($params['navnom']), $params['nom'], '');
$keywords = "";
if (isset($params['keywords']) && !empty($params['keywords'])) {
$keywords = $params['keywords'];
} else {
$navnomStrip = explode("-", $navnom);
for ($index = 0; $index < sizeof($navnomStrip); $index++) {
$word = $navnomStrip[$index];
if (empty($keywords)) {
if (strlen($word) > 3){ $keywords .= $word; }
} else {
if (strlen($word) > 3){ $keywords .= ",".$word; }
}
}
}
//Refractor the params
$data = array (
'NAVTITRENOM' => $filter->filter($params['navtitrenom']),
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'NAVDESCRIPTION' => $filter->filter($params['navdescription'])
);
if ($validator->isValid($data['NAVNOM']) &&
$validator->isValid($data['KEYWORDS'])) {
if (empty($data['NAVTITRENOM'])) {
$data['NAVTITRENOM'] = $filter->filter($params['nom']);
}
if (empty($data['NAVDESCRIPTION'])) {
$data['NAVDESCRIPTION'] = "";
}
try {
$id = $params['id'];
$category = new Category();
if (isset($params['urlaccess']) && $params['idparent'] == 0) {
$data['NAVNOM_URLPARENTS'] = $this->verifyNavigationString('',$filter->filter($params['urlaccess']), '');
}
if (empty($data['NAVNOM_URLPARENTS'])) {
$data['NAVNOM_URLPARENTS'] = $category->getTreeInLineAsPathOf($id);
if (empty($data['NAVNOM_URLPARENTS'])) {
$data['NAVNOM_URLPARENTS'] = $navnom;
}
}
$category->update($data, 'ID = '.$id);
$nbSubs = $category->updateTreeInLineAsPathOfChilds($id, false);
$this->view->messageSuccess = "La cat�gorie a �t� modifi�e, ".$nbSubs." urls d'acc�s modifi�es.";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = "La cat�gorie existe d�j�";
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
}
}
$this->_forward('/edit');
}
function editthemeAction()
{
$this->view->titlePage = "Modifier le th�me";
if ($this->_request->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'ID_THEME' => $params['idtheme']
);
try {
$id = (int)$params['id'];
$category = new Category();
$category->update($data, 'ID = '.$id);
$this->view->messageSuccess = "Le th�me a �t� modifi�";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
$this->_forward('/edit');
}
function editactiveAction()
{
$this->view->titlePage = "Modifier une cat�gorie";
if ($this->_request->isPost()) {
//get the form params
$params = $this->_request->getPost();
//Refractor the params
$data = array (
'isACTIVE' => $params['active']
);
try {
$id = (int)$params['id'];
$category = new Category();
$category->update($data, 'ID = '.$id);
//inversement des bool
if ($data['isACTIVE'] == 1) {
$data['isACTIVE'] = 0;
} else {
$data['isACTIVE'] = 1;
}
$dataProduct = array(
'isACTIVE' => $data['isACTIVE']
);
$produit = new Product();
$nb = $produit->updateByCategory($id, $dataProduct);
$this->view->messageSuccess = "La cat�gorie a �t� modifi�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
$this->_forward('/edit');
}
function addAction()
{
$this->view->titlePage = "Ajouter une cat�gorie";
$this->view->messageSuccess = "";
$this->view->messageError = "";
if ($this->_request->isPost()) {
//filtres pour changer les chaines
$filter = new Zend_Filter();
$filter ->addFilter(new Zend_Filter_StripTags())
->addFilter(new Zend_Filter_StringTrim());
//valideurs pour les chaines
$validator = new Zend_Validate();
$validator -> addValidator(new Zend_Validate_NotEmpty());
//get the form params
$params = $this->_request->getPost();
$navnom = $this->verifyNavigationString($filter->filter($params['navnom']), $params['nom'], '');
$keywords = "";
if (isset($params['keywords']) && !empty($params['keywords'])) {
$keywords = $params['keywords'];
} else {
$navnomStrip = explode("-", $navnom);
for ($index = 0; $index < sizeof($navnomStrip); $index++) {
$word = $navnomStrip[$index];
if (empty($keywords)) {
if (strlen($word) > 3){ $keywords .= $word; }
} else {
if (strlen($word) > 3){ $keywords .= ",".$word; }
}
}
}
$data = array (
'NOM' => $filter->filter($params['nom']),
'NAVTITRENOM' => $filter->filter($params['nom']),
'DESCRIPTION' => $filter->filter($params['desc']),
'NAVDESCRIPTION' => $filter->filter($params['desc']),
'NAVNOM' => $navnom,
'KEYWORDS' => $keywords,
'IDPARENT' => $filter->filter($params['idparent'])
);
if ($validator->isValid($data['NOM']) &&
$validator->isValid($data['NAVNOM'])
) {
try {
$category = new Category();
$data['NAVNOM_URLPARENTS'] = $category->getTreeInLineAsPathOf($data['IDPARENT']);
if (empty($data['NAVNOM_URLPARENTS'])) {
$data['NAVNOM_URLPARENTS'] = $navnom;
}
$category->insert($data);
//create items folder for pics
$lastid = $category->getAdapter()->lastInsertId();
if ($lastid > 0) {
$this->checkDirectoryExist("items/category/".$lastid);
$this->checkDirectoryExist("items/product/".$lastid);
$this->view->messageSuccess = "La cat�gorie a �t� ajout�e";
if($this->uploadNewPicsAndSave($lastid)) {
$this->view->messageSuccess .= " , l'image a �t� upload�e";
}
$this->log("La cat�gorie a �t� ajout�e",'info');
//Listing Categories
$category = new Category();
$this->view->listallcategories = $category->getAllCategoriesByID(0);
$this->_request->setParam('id', $lastid);
$this->_forward('/edit');
}
} catch (Zend_Exception $e) {
$this->view->messageError = "La cat�gorie existe d�j�";
$this->log($e->getMessage(),'err');
$this->view->populateForm = $data;
}
} else {
foreach ($validator->getErrors() as $errorCode) {
$this->view->messageError .= $this->getErrorValidator($errorCode);
}
$this->view->populateForm = $data;
}
}
}
function uploadNewPics($idCat, $field) {
if(!empty($_FILES[$field]) && !empty($_FILES[$field]['name'])) {
$nomOrigine = $_FILES[$field]['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpg", "jpeg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
$repertoireDestination = 'items/category/'.$idCat.'/';
$this->checkDirectoryExist($repertoireDestination);
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
$fileoriginal = $repertoireDestination.$nomDestination;
if (move_uploaded_file($_FILES[$field]["tmp_name"],$fileoriginal)) {
//Resize picture
$info = getimagesize($fileoriginal) ;
list($width_old, $height_old) = $info;
$maxwidth = $this->FeaturePictureResizeWidth;
$maxheight = $this->FeaturePictureResizeHeight;
if ($width_old > $maxwidth || $height_old > $maxheight) {
Utils_Tool::smart_resize_image($fileoriginal , null, $maxwidth , $maxheight , true , $fileoriginal , true , false ,50 );
}
return $repertoireDestination.$nomDestination;
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
}
return "";
}
function uploadNewPicsAndSave($idCat) {
$url = $this->uploadNewPics($idCat, 'picCat');
if(!empty($url)) {
try {
$category = new Category();
$data = array (
'URL' => $url
);
$category->update($data,'ID = '.$idCat);
return true;
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
return false;
}
}
return false;
}
function uploadNewPicsSlideAndSave($idCat) {
$url = $this->uploadNewPics($idCat, 'picSlideCat');
if(!empty($url)) {
try {
$category = new Category();
$data = array (
'URL_SLIDE' => $url
);
$category->update($data,'ID = '.$idCat);
return true;
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
return false;
}
}
return false;
}
function uploadNewChoicePics($idCat) {
if(!empty($_FILES['picChoice']) && !empty($_FILES['picChoice']['name'])) {
$nomOrigine = $_FILES['picChoice']['name'];
$elementsChemin = pathinfo($nomOrigine);
$extensionFichier = strtolower($elementsChemin['extension']);
$extensionsAutorisees = array("jpg", "jpeg", "gif", "png");
if (!(in_array($extensionFichier, $extensionsAutorisees))) {
$this->view->messageError = "Le fichier n'a pas l'extension attendue";
} else {
// Copie dans le repertoire du script avec un nom
// incluant l'heure a la seconde pres
$repertoireDestination = 'items/category_choice/'.$idCat.'/';
$this->checkDirectoryExist($repertoireDestination);
$date = new Zend_Date();
//$nomDestination = $date->toString('dd-MM-YYYY_HH-mm-ss').".".$extensionFichier;
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
if (move_uploaded_file($_FILES["picChoice"]["tmp_name"],$repertoireDestination.$nomDestination)) {
try {
$category = new Category();
$data = array (
'CHOICEURL' => $repertoireDestination.$nomDestination
);
$category->update($data,'ID = '.$idCat);
return true;
} catch (Exception $e) {
$this->view->messageError = $e->getMessage();
return false;
}
} else {
$this->view->messageError = "Le fichier n'a pas �t� upload�";
}
}
}
return false;
}
function setpictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category();
if (isset($params['typeimage']) && $params['typeimage'] == 1) {
$data = array (
'URL_SLIDE' => $params['picture']
);
} else {
$data = array (
'URL' => $params['picture']
);
}
$category->update($data,'ID = '.$params['idCat']);
$this->view->messageSuccess = "L'image a �t� modifi�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
function erasepictureAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category();
unlink($params['picture']);
$data = array (
'URL' => ''
);
$category->update($data,"ID = ".$params['idCat']." AND URL = '".$params['picture']."'");
$this->view->messageSuccess = "L'image a �t� supprim�e d�finitivement";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
function setpicturechoiceAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category();
$data = array (
'CHOICEURL' => $params['picture']
);
$category->update($data,'ID = '.$params['idCat']);
$this->view->messageSuccess = "L'image a �t� modifi�e";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
function erasepicturechoiceAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
try {
$category = new Category();
unlink($params['picture']);
$data = array (
'CHOICEURL' => ''
);
$category->update($data,"ID = ".$params['idCat']." AND CHOICEURL = '".$params['picture']."'");
$this->view->messageSuccess = "L'image a �t� supprim�e d�finitivement";
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
$this->view->messageError = $e->getMessage();
}
}
$this->_forward('/edit');
}
function deletegalleryAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id') && $this->_request->getParam('idgallery')) {
$id = (int)$this->_request->getParam('id');
$idgallery = (int)$this->_request->getParam('idgallery');
if ($id > 0 && $idgallery > 0) {
try {
$annonce = new AnnonceGallery();
$dataAnnonceCurrent = $annonce->fetchRow('ID = '.$idgallery);
$dataAnnonce = array (
'ID_CATS' => str_replace(":".$id.":", "", $dataAnnonceCurrent['ID_CATS'])
);
$annonce->update($dataAnnonce,'ID = '.$idgallery);
$this->view->messageSuccess = "L'image a �t� supprim�e de la cat�gorie";
$this->log("L'image ".$idgallery." a �t� supprim�e de la cat�gorie".$id,'info');
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/edit');
}
function deletecmsAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->getParam('id') && $this->_request->getParam('idarticle')) {
$id = (int)$this->_request->getParam('id');
$idarticle = (int)$this->_request->getParam('idarticle');
if ($id > 0 && $idarticle > 0) {
try {
$annonce = new AnnonceCms();
$dataAnnonceCurrent = $annonce->fetchRow('ID = '.$idarticle);
$dataAnnonce = array (
'ID_CATS' => str_replace(":".$id.":", "", $dataAnnonceCurrent['ID_CATS'])
);
$annonce->update($dataAnnonce,'ID = '.$idarticle);
$this->view->messageSuccess = "L'article a �t� supprim� de la cat�gorie";
$this->log("L'article ".$idarticle." a �t� supprim� de la cat�gorie".$id,'info');
} catch (Zend_Exception $e) {
$this->view->messageError = $e->getMessage();
$this->log($e->getMessage(),'err');
}
}
}
$this->_forward('/edit');
}
function addmultiplegalleryAction() {
$this->view->messageSuccess = "";
$this->view->messageError = "";
if($this->_request->isPost()) {
$params = $this->_request->getPost();
$id = (int)$this->_request->getParam('idCat');
$annonce = new AnnonceGallery();
if ($id > 0) {
$dataAnnonce = array (
'NOM' => "",
'CONTENT' => "",
'CONTENT_SHORT' => "",
'CONTENT_LONG' => "",
'POSITION' => 0,
'isSHOW' => 0,
'ID_CATS' => ":".$id.":"
);
try {
$annonce->insert($dataAnnonce);
$lastid = $annonce->getAdapter()->lastInsertId();
$result = $this->uploadHandlerFileUpload($lastid);
if (isset($result['success']) && $result['success'] == true) {
$this->log("L'image a �t� ajout�e ".$lastid ,'info');
} else {
$annonce->delete('ID = '.$lastid);
$this->delete_directory('items/gallery/'.$lastid);
$this->log("L'image a �t� ajout�e puis supprim�e : ".$result['error'],'err');
}
echo json_encode($result);
} catch (Zend_Exception $e) {
$this->log($e->getMessage(),'err');
}
}
}
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$this->render('ajaxvalue');
}
function uploadHandlerFileUpload($id) {
$uploader = new UploadHandler();
$uploader->allowedExtensions = array("jpg", "jpeg", "gif", "png");
$uploader->sizeLimit = null;
$uploader->inputName = "qqfile";
$repertoireGallery = 'items/gallery/';
$_REQUEST['qquuid'] = $id;
$currentName = '';
if (isset($_REQUEST['qqfilename'])) {
$currentName = $_REQUEST['qqfilename'];
} else if (isset($_FILES[$uploader->inputName])) {
$currentName = $_FILES[$uploader->inputName]['name'];
}
$elementsChemin = pathinfo($currentName);
$extensionFichier = strtolower($elementsChemin['extension']);
$nomDestination = $this->generateNavigationString($elementsChemin['filename']).".".$extensionFichier;
// If you want to use the chunking/resume feature, specify the folder to temporarily save parts.
$this->checkDirectoryExist($repertoireGallery."chunks");
$uploader->chunksFolder = $repertoireGallery."chunks";
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload($repertoireGallery, $nomDestination);
if (isset($result['success']) && $result['success'] == true) {
$repertoireDestination = $repertoireGallery.$id."/";
$fileoriginal = $repertoireDestination.$nomDestination;
//Resize picture
$fileResizedName = $repertoireDestination.$this->generateNavigationString($elementsChemin['filename']);
//Admin
Utils_Tool::smart_resize_image($fileoriginal , null, 100 , null , true , $fileResizedName."_100.".$extensionFichier , false , false ,80 );
if (isset($this->FeatureSiteThemeCms) && !empty($this->FeatureSiteThemeCms)) {
foreach ($this->FeatureSiteThemeCms as $row) {
if (isset($row['WIDTH_THUMB']) && $row['WIDTH_THUMB'] > 0) {
Utils_Tool::smart_resize_image($fileoriginal , null, $row['WIDTH_THUMB'] , null , true , $fileResizedName."_".$row['WIDTH_THUMB'].".".$extensionFichier , false , false ,80 );
}
}
}
//Save url
$url = $repertoireDestination.$result["uploadName"];
if(!empty($url)) {
try {
$annonce = new AnnonceGallery();
$data = array ( 'URL' => $url, 'NOM' => $elementsChemin['filename'] );
$annonce->update($data,'ID = '.$id);
} catch (Exception $e) {
$this->log($e->getMessage(),'err');
}
}
}
return $result;
}
}
?>PK �0H[�\�ϻ% �% StatisticController.phpnu &1i� PK �0H[`�;= ;= &