diff --git a/htdocs/includes/triggers/interface_modPropale_Exportsynchro.class.php-NORUN b/htdocs/includes/triggers/interface_modPropale_Exportsynchro.class.php-NORUN deleted file mode 100644 index bcbae646407..00000000000 --- a/htdocs/includes/triggers/interface_modPropale_Exportsynchro.class.php-NORUN +++ /dev/null @@ -1,216 +0,0 @@ - - * Copyright (C) 2009 William Piedfort - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - \file htdocs/includes/triggers/interface_modPropale_Exportsynchro.class.php - \ingroup propale - \brief Trigger file for - \version $Id$ -*/ - - -/** - \class InterfaceExportsynchro - \brief Classe des fonctions triggers des actions personalisees du workflow -*/ - -class InterfaceExportsynchro -{ - var $db; - - /** - * Constructor. - * @param DB Database handler - */ - function InterfaceExportsynchro($DB) - { - $this->db = $DB ; - - $this->name = preg_replace('/^Interface/i','',get_class($this)); - $this->family = "propale"; - $this->description = "Triggers of this module allows to export signed propal for synchro with an other application. (in csv files)"; - $this->version = 'development'; // 'development', 'experimental', 'dolibarr' or version - } - - - /** - * Return name of trigger file - * @return string Name of trigger file - */ - function getName() - { - return $this->name; - } - - /** - * Return description of trigger file - * @return string Description of trigger file - */ - function getDesc() - { - return $this->description; - } - - /** - * Return version of trigger file - * @return string Version of trigger file - */ - function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') return $langs->trans("Development"); - elseif ($this->version == 'experimental') return $langs->trans("Experimental"); - elseif ($this->version == 'dolibarr') return DOL_VERSION; - elseif ($this->version) return $this->version; - else return $langs->trans("Unknown"); - } - - /** - * Function called when a Dolibarrr business event is done. - * All functions "run_trigger" are triggered if file is inside directory htdocs/includes/triggers - * @param action Event code (COMPANY_CREATE, PROPAL_VALIDATE, ...) - * @param object Object action is done on - * @param user Object user - * @param langs Object langs - * @param conf Object conf - * @return int <0 if KO, 0 if no action are done, >0 if OK - */ - function run_trigger($action,$object,$user,$langs,$conf) - { - if (empty($conf->propale->enabled)) return 0; // Module not active, we do nothing - - // Proposals - if ($action == 'PROPAL_CLOSE_SIGNED') - { - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - return $this->_create_csv_files($action,$object,$user,$langs,$conf); - } - - return 0; - } - - - /** - * Create a CVS export file - */ - function _create_csv_files($action,$object,$user,$langs,$conf) - { - include_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); - include_once(DOL_DOCUMENT_ROOT."/societe.class.php"); - - $propal_filename = $conf->propale->dir_temp.'/propal_exportsynchro.csv'; - $propalLines_filename = $conf->propale->dir_temp.'/propal_lines_exportsynchro.csv'; - $separator = ','; - - if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET)) - { - $langs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET; - } - else - { - $langs->charset_output = 'ISO-8859-1'; - } - - $propal = new Propal($this->db); - $propal->fetch($object->id); - - $societe = new Societe($this->db, $propal->socid); - $societe->fetch($propal->socid); - - // Create propal csv file - $objPropal = array( "CompanyName"=>$societe->nom, - "Zip"=>$societe->cp, - "Ref"=>$propal->ref, - "RefClient"=>$propal->ref_client, - "DateCreation"=>$propal->datec - ); - - if(!file_exists($propal_filename)) - { - $this->handle = fopen($propal_filename, "wt"); - - foreach ($objPropal as $head => $value) - { - $field = $langs->transnoentities($head); - fwrite($this->handle,$field.$separator); - } - fwrite($this->handle,"\n"); - fclose($this->handle); - } - - $this->handle = fopen($propal_filename, "a+"); - - foreach ($objPropal as $head => $value) - { - fwrite($this->handle,$value.$separator); - } - fwrite($this->handle,"\n"); - fclose($this->handle); - - // Create propal lines csv files - $objPropalLine_head = array( "Ref", - "ProductRef", - "Label", - "LineQty", - "LineTotalHT" - ); - - $i=0; - while ($i < count($propal->lines)) - { - $objPropalLine_data[$i] = array( "Ref"=>$propal->ref, - "ProductRef"=>$propal->lines[$i]->ref, - "Label"=>$propal->lines[$i]->libelle, - "LineQty"=>$propal->lines[$i]->qty, - "LineTotalHT"=>$propal->lines[$i]->total_ht - ); - $i++; - } - - if(!file_exists($propalLines_filename)) - { - $this->handle = fopen($propalLines_filename, "wt"); - - foreach ($objPropalLine_head as $value) - { - $field = $langs->transnoentities($value); - fwrite($this->handle,$field.$separator); - } - fwrite($this->handle,"\n"); - fclose($this->handle); - } - - $this->handle = fopen($propalLines_filename, "a+"); - $i=0; - while ($i < count($objPropalLine_data)) - { - foreach ($objPropalLine_data[$i] as $head => $value) - { - fwrite($this->handle,$value.$separator); - } - fwrite($this->handle,"\n"); - $i++; - } - fclose($this->handle); - } - -} -?>