Current File : /home/karenpetzb/application/modules/backoffice/controllers/MaintenanceController.php |
<?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');
}
}