diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 6281b1f25f4..189f1f9c041 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -617,11 +617,12 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G else $subject = $langs->transnoentities('Propal') . ' ' . $object->ref; $actiontypecode = 'AC_PROP'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 47dfb568c78..792da64a923 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1225,11 +1225,12 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G else $subject = $langs->transnoentities('Order') . ' ' . $object->ref; $actiontypecode = 'AC_COM'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); } @@ -1295,18 +1296,10 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G setEventMessage($mesg, 'errors'); } } - /* } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - $action='presend'; - dol_syslog('Recipient email is empty'); - }*/ } else { - $langs->load("errors"); - setEventMessage($langs->trans('ErrorCantReadFile', $file), 'errors'); - dol_syslog('Failed to read file: ' . $file); + $langs->load("other"); + setEventMessage($langs->trans('ErrorMailRecipientIsEmpty') . '!', 'errors'); + dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); } } else { $langs->load("other"); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 58001d5c918..2ba425f5a90 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1615,8 +1615,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $sendtoid = $_POST['receiver']; } } - - if (dol_strlen($sendto)) { + + if (dol_strlen($sendto)) + { $langs->load("commercial"); $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>'; @@ -1626,31 +1627,19 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO); $deliveryreceipt = $_POST['deliveryreceipt']; - if ($action == 'send') { + if ($action == 'send' || $action == 'relance') + { if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; else $subject = $langs->transnoentities('Bill') . ' ' . $object->ref; $actiontypecode = 'AC_FAC'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; - } - // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - if ($action == 'relance') { - if (dol_strlen($_POST['subject'])) - $subject = $_POST['subject']; - else - $subject = $langs->transnoentities('Relance facture ' . $object->ref); - $actiontypecode = 'AC_FAC'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } @@ -1660,9 +1649,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $formmail = new FormMail($db); $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles ['paths']; - $filename = $attachedfiles ['names']; - $mimetype = $attachedfiles ['mimes']; + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; // Send mail require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; @@ -1715,17 +1704,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO setEventMessage($mesg, 'errors'); } } - /* } - else - { - $langs->load("other"); - $mesgs[]='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; - dol_syslog('Recipient email is empty'); - }*/ } else { - $langs->load("errors"); - setEventMessage($langs->trans('ErrorCantReadFile', $file), 'errors'); - dol_syslog('Failed to read file: ' . $file); + $langs->load("other"); + setEventMessage($langs->trans('ErrorMailRecipientIsEmpty') . '!', 'errors'); + dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); } } else { $langs->load("other"); diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index ea0d896f5d1..320d86f3377 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -136,12 +136,13 @@ if ($action == 'presend' && GETPOST('sendmail')) $message=make_substitutions($message, $substitutionarray); $actiontypecode='AC_FAC'; - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Create form object diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 337cf59c9b0..625376ace58 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -126,13 +126,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($action == 'send' || $action == 'relance') { if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; - $actionmsg2=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + $actionmsg2=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; + $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } } diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 407893021ef..199c342020d 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -31,7 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class Interfaces { - var $dir; // Directory with all core and external triggers files + var $db; + var $dir; // Directory with all core and external triggers files var $errors = array(); // Array for errors /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 23092acfd0d..a94a77f1454 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2862,7 +2862,11 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou $listofcurrenciesbefore=array('USD'); if (in_array($currency_code,$listofcurrenciesbefore)) $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code); - else $cursymbolafter.=$outlangs->getCurrencySymbol($currency_code); + else + { + $tmpcur=$outlangs->getCurrencySymbol($currency_code); + $cursymbolafter.=($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur); + } } $output=$cursymbolbefore.$output.$end.$cursymbolafter; diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index d5be39aff0f..ccc115b5b1d 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -41,12 +41,13 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); * @param date $paymentdatebefore Payment before date (must includes hour) * @param int $usestdout Add information onto standard output * @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template - * @param string $option Suffix to add into file name of generated PDF + * @param string $filesuffix Suffix to add into file name of generated PDF * @param string $paymentbankid Only if payment on this bank account id * @param array $thirdpartiesid List of thirdparties id when using filter excludethirdpartiesid or onlythirdpartiesid + * @param string $fileprefix Prefix to add into filename of generated PDF * @return int Error code */ -function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $option='', $paymentbankid='', $thirdpartiesid='') +function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $filesuffix='', $paymentbankid='', $thirdpartiesid='', $fileprefix='mergedpdf') { $sql = "SELECT DISTINCT f.rowid, f.facnumber"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; @@ -220,13 +221,6 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); //$pdf->SetCompression(false); - - //$pdf->Open(); - //$pdf->AddPage(); - //$title=$langs->trans("BillsCustomersUnpaid"); - //if ($option=='late') $title=$langs->trans("BillsCustomersUnpaid"); - //$pdf->MultiCell(100, 3, $title, 0, 'J'); - // Add all others foreach($files as $file) { @@ -248,9 +242,9 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte dol_mkdir($diroutputpdf); // Save merged file - $filename='mergedpdf'; - - if (! empty($option)) $filename.='_'.$option; + $filename=$fileprefix; + if (empty($filename)) $filename='mergedpdf'; + if (! empty($filesuffix)) $filename.='_'.$filesuffix; $file=$diroutputpdf.'/'.$filename.'.pdf'; if (! $error && $pagecount) diff --git a/htdocs/core/modules/modSyncSupplierWebServices.class.php b/htdocs/core/modules/modSyncSupplierWebServices.class.php new file mode 100755 index 00000000000..088989f9de4 --- /dev/null +++ b/htdocs/core/modules/modSyncSupplierWebServices.class.php @@ -0,0 +1,121 @@ + + * + * 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 3 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, see . + */ + +/** + * \defgroup webservices Module webservices + * \brief Module to enable client for supplier WebServices + * \file htdocs/core/modules/modSyncSupplierWebServices.class.php + * \ingroup webservices + * \brief File to describe client for supplier webservices module + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + +/** + * Class to describe a WebServices module + */ +class modSyncSupplierWebServices extends DolibarrModules +{ + + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + $this->numero = 2650; + + $this->family = "technic"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + $this->description = "Enable the client for external supplier web services"; + $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) + $this->special = 1; + // Name of image file used for this module. + $this->picto='technic'; + + // Data directories to create when module is enabled + $this->dirs = array(); + + // Config pages + //------------- + //$this->config_page_url = array("webservices.php@webservices"); + + // Dependancies + //------------- + $this->depends = array(); + $this->requiredby = array(); + $this->langfiles = array("other"); + + // Constantes + //----------- + $this->const = array(); + + // New pages on tabs + // ----------------- + $this->tabs = array(); + + // Boxes + //------ + $this->boxes = array(); + + // Permissions + //------------ + $this->rights = array(); + $this->rights_class = 'syncsupplierwebservices'; + $r=0; + } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + // Prevent pb of modules not correctly disabled + //$this->remove($options); + + $sql = array(); + + return $this->_init($sql,$options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function remove($options='') + { + $sql = array(); + + return $this->_remove($sql,$options); + } + +} diff --git a/htdocs/core/triggers/dolibarrtriggers.class.php b/htdocs/core/triggers/dolibarrtriggers.class.php index 1fd29359d74..0682bb76a71 100644 --- a/htdocs/core/triggers/dolibarrtriggers.class.php +++ b/htdocs/core/triggers/dolibarrtriggers.class.php @@ -83,7 +83,8 @@ abstract class DolibarrTriggers $this->db = $db; - if (!isset($this->name)) { + if (empty($this->name)) + { $this->name = preg_replace('/^Interface/i', '', get_class($this)); } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 632acf71b0e..d4fe47c0faa 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -222,7 +222,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } - + // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 7db0ecc56b1..8984e4c5424 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -462,12 +462,13 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile' if (dol_strlen(GETPOST('subject','alpha'))) $subject=GETPOST('subject','alpha'); else $subject = $langs->transnoentities('Shipping').' '.$object->ref; $actiontypecode='AC_SHIP'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index b5e874d03a6..77c7e17ffb5 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -745,12 +745,13 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA if (strlen(GETPOST('subject','alphs'))) $subject = GETPOST('subject','alpha'); else $subject = $langs->transnoentities('Intervention').' '.$object->ref; $actiontypecode='AC_OTH_AUTO'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index da4f13e6d53..0273dea94b9 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2011 Philippe Grand * Copyright (C) 2012 Marcos García * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014 Ion Agorria * * 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 @@ -43,7 +44,9 @@ if (!empty($conf->produit->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP +$langs->load('admin'); $langs->load('orders'); $langs->load('sendings'); $langs->load('companies'); @@ -941,12 +944,13 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G if (dol_strlen(GETPOST('subject'))) $subject=GETPOST('subject'); else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; $actiontypecode='AC_SUP_ORD'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } @@ -1044,6 +1048,99 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G } } +if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('cancel')) +{ + $ws_url = $object->thirdparty->webservices_url; + $ws_key = $object->thirdparty->webservices_key; + $ws_user = GETPOST('ws_user','alpha'); + $ws_password = GETPOST('ws_password','alpha'); + $ws_entity = GETPOST('ws_entity','int'); + $ws_thirdparty = GETPOST('ws_thirdparty','int'); + + // NS and Authentication parameters + $ws_ns='http://www.dolibarr.org/ns/'; + $ws_authentication=array( + 'dolibarrkey'=>$ws_key, + 'sourceapplication'=>'DolibarrWebServiceClient', + 'login'=>$ws_user, + 'password'=>$ws_password, + 'entity'=>$ws_entity + ); + + //Is sync supplier web services module activated? and everything filled? + if (empty($conf->syncsupplierwebservices->enabled)) { + setEventMessage($langs->trans("WarningModuleNotActive",$langs->transnoentities("Module2650Name"))); + } else if (empty($ws_url) || empty($ws_key)) { + setEventMessage($langs->trans("ErrorWebServicesFieldsRequired"), 'errors'); + } else if (empty($ws_user) || empty($ws_password) || empty($ws_thirdparty)) { + setEventMessage($langs->trans("ErrorFieldsRequired"), 'errors'); + } + else + { + //Create SOAP client and connect it to order + $soapclient_order = new nusoap_client($ws_url."/webservices/server_order.php"); + $soapclient_order->soap_defencoding='UTF-8'; + $soapclient_order->decodeUTF8(false); + + //Create SOAP client and connect it to product/service + $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); + $soapclient_product->soap_defencoding='UTF-8'; + $soapclient_product->decodeUTF8(false); + + //Prepare the order lines from order + $order_lines = array(); + foreach ($object->lines as $line) + { + $ws_parameters = array('authentication' => $ws_authentication, 'id' => '', 'ref' => $line->ref_supplier); + $result_product = $soapclient_product->call("getProductOrService", $ws_parameters, $ws_ns, ''); + + if ($result_product["result"]["result_code"] == "OK") + { + $order_lines[] = array( + 'desc' => $line->product_desc, + 'type' => $line->product_type, + 'product_id' => $result_product["product"]["id"], + 'vat_rate' => $line->tva_tx, + 'qty' => $line->qty, + 'price' => $line->price, + 'unitprice' => $line->subprice, + 'total_net' => $line->total_ht, + 'total_vat' => $line->total_tva, + 'total' => $line->total_ttc, + 'date_start' => $line->date_start, + 'date_end' => $line->date_end, + ); + } + } + + //Prepare the order header + $order = array( + 'thirdparty_id' => $ws_thirdparty, + 'date' => dol_print_date(dol_now(),'dayrfc'), + 'total_net' => $object->total_ht, + 'total_var' => $object->total_tva, + 'total' => $object->total_ttc, + 'lines' => $order_lines + ); + + $ws_parameters = array('authentication'=>$ws_authentication, 'order' => $order); + $result_order = $soapclient_order->call("createOrder", $ws_parameters, $ws_ns, ''); + + if (empty($result_order["result"]["result_code"])) //No result, check error str + { + setEventMessage($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", 'errors'); + } + else if ($result_order["result"]["result_code"] != "OK") //Something went wrong + { + setEventMessage($langs->trans("SOAPError")." '".$result_order["result"]["result_code"]."' - '".$result_order["result"]["result_label"]."'", 'errors'); + } + else + { + setEventMessage($langs->trans("RemoteOrderRef")." ".$result_order["ref"], 'mesgs'); + } + } +} + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->commande->creer) { if ($action == 'addcontact') @@ -1769,7 +1866,324 @@ elseif (! empty($object->id)) dol_fiche_end(); - if ($action != 'presend') + /* + * Action presend + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref,'/')); + $file=$fileparams['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + + if (!empty($newlang)) + { + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->load('commercial'); + } + + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + $result= $object->generateDocument(GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref,'/')); + $file=$fileparams['fullname']; + } + + print '
'; + + print_titre($langs->trans('SendOrderByMail')); + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; + $formmail->withtocc=$liste; + $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); + $formmail->withtopic=$outputlangs->trans('SendOrderRef','__ORDERREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + // Tableau des substitutions + $formmail->substit['__ORDERREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=$user->signature; + $formmail->substit['__PERSONALIZED__']=''; + $formmail->substit['__CONTACTCIVNAME__']=''; + + //Find the good contact adress + $custcontact=''; + $contactarr=array(); + $contactarr=$object->liste_contact(-1,'external'); + + if (is_array($contactarr) && count($contactarr)>0) { + foreach($contactarr as $contact) { + if ($contact['libelle']==$langs->trans('TypeContact_order_supplier_external_BILLING')) { + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $contactstatic=new Contact($db); + $contactstatic->fetch($contact['id']); + $custcontact=$contactstatic->getFullName($langs,1); + } + } + + if (!empty($custcontact)) { + $formmail->substit['__CONTACTCIVNAME__']=$custcontact; + } + } + + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='order_supplier_send'; + $formmail->param['orderid']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + // Init list of files + if (GETPOST("mode")=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); + } + + // Show form + print $formmail->get_form(); + + print '
'; + } + /* + * Action webservice + */ + elseif ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && ! GETPOST('cancel')) + { + $mode = GETPOST('mode', 'alpha'); + $ws_url = $object->thirdparty->webservices_url; + $ws_key = $object->thirdparty->webservices_key; + $ws_user = GETPOST('ws_user','alpha'); + $ws_password = GETPOST('ws_password','alpha'); + + // NS and Authentication parameters + $ws_ns = 'http://www.dolibarr.org/ns/'; + $ws_authentication = array( + 'dolibarrkey'=>$ws_key, + 'sourceapplication'=>'DolibarrWebServiceClient', + 'login'=>$ws_user, + 'password'=>$ws_password, + 'entity'=>'' + ); + + print_titre($langs->trans('CreateRemoteOrder')); + + //Is everything filled? + if (empty($ws_url) || empty($ws_key)) { + setEventMessage($langs->trans("ErrorWebServicesFieldsRequired"), 'errors'); + $mode = "init"; + $error_occurred = true; //Don't allow to set the user/pass if thirdparty fields are not filled + } else if ($mode != "init" && (empty($ws_user) || empty($ws_password))) { + setEventMessage($langs->trans("ErrorFieldsRequired"), 'errors'); + $mode = "init"; + } + + if ($mode == "init") + { + //Table/form header + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($error_occurred) + { + print "
".$langs->trans("ErrorOccurredReviseAndRetry")."
"; + print ''; + } + else + { + $textinput_size = "50"; + // Webservice url + print ''; + //Remote User + print ''; + //Remote Password + print ''; + //Submit button + print ''; + } + + //End table/form + print ''; + print '
'.$langs->trans("WebServiceURL").''.dol_print_url($ws_url).'
'.$langs->trans("User").'
'.$langs->trans("Password").'
'; + print ''; + print '     '; + //Cancel button + print ''; + print '
'; + } + elseif ($mode == "check") + { + $ws_entity = ''; + $ws_thirdparty = ''; + $error_occurred = false; + + //Create SOAP client and connect it to user + $soapclient_user = new nusoap_client($ws_url."/webservices/server_user.php"); + $soapclient_user->soap_defencoding='UTF-8'; + $soapclient_user->decodeUTF8(false); + + //Get the thirdparty associated to user + $ws_parameters = array('authentication'=>$ws_authentication, 'id' => '', 'ref'=>$ws_user); + $result_user = $soapclient_user->call("getUser", $ws_parameters, $ws_ns, ''); + $user_status_code = $result_user["result"]["result_code"]; + + if ($user_status_code == "OK") + { + //Fill the variables + $ws_entity = $result_user["user"]["entity"]; + $ws_authentication['entity'] = $ws_entity; + $ws_thirdparty = $result_user["user"]["fk_thirdparty"]; + if (empty($ws_thirdparty)) + { + setEventMessage($langs->trans("RemoteUserMissingAssociatedSoc"), 'errors'); + $error_occurred = true; + } + else + { + //Create SOAP client and connect it to product/service + $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); + $soapclient_product->soap_defencoding='UTF-8'; + $soapclient_product->decodeUTF8(false); + + // Iterate each line and get the reference that uses the supplier of that product/service + $i = 0; + foreach ($object->lines as $line) { + $i = $i + 1; + $ref_supplier = $line->ref_supplier; + $line_id = $i."º) ".$line->product_ref.": "; + if (empty($ref_supplier)) { + continue; + } + $ws_parameters = array('authentication' => $ws_authentication, 'id' => '', 'ref' => $ref_supplier); + $result_product = $soapclient_product->call("getProductOrService", $ws_parameters, $ws_ns, ''); + if (!$result_product) + { + setEventMessage($line_id.$langs->trans("SOAPError")." ".$soapclient_product->error_str." - ".$soapclient_product->response, 'errors'); + $error_occurred = true; + break; + } + + // Check the result code + $status_code = $result_product["result"]["result_code"]; + if (empty($status_code)) //No result, check error str + { + setEventMessage($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", 'errors'); + } + else if ($status_code != "OK") //Something went wrong + { + if ($status_code == "NOT_FOUND") + { + setEventMessage($line_id.$langs->trans("SupplierMissingRef")." '".$ref_supplier."'", 'warnings'); + } + else + { + setEventMessage($line_id.$langs->trans("ResponseNonOK")." '".$status_code."' - '".$result_product["result"]["result_label"]."'", 'errors'); + $error_occurred = true; + break; + } + } + + + // Ensure that price is equal and warn user if it's not + $supplier_price = price($result_product["product"]["price_net"]); //Price of client tab in supplier dolibarr + $local_price = NULL; //Price of supplier as stated in product suppliers tab on this dolibarr, NULL if not found + + $product_fourn = new ProductFournisseur($db); + $product_fourn_list = $product_fourn->list_product_fournisseur_price($line->fk_product); + if (count($product_fourn_list)>0) + { + foreach($product_fourn_list as $product_fourn_line) + { + //Only accept the line where the supplier is the same at this order and has the same ref + if ($product_fourn_line->fourn_id == $object->socid && $product_fourn_line->fourn_ref == $ref_supplier) { + $local_price = price($product_fourn_line->fourn_price); + } + } + } + + if ($local_price != NULL && $local_price != $supplier_price) { + setEventMessage($line_id.$langs->trans("RemotePriceMismatch")." ".$supplier_price." - ".$local_price, 'warnings'); + } + + // Check if is in sale + if (empty($result_product["product"]["status_tosell"])) { + setEventMessage($line_id.$langs->trans("ProductStatusNotOnSellShort")." '".$ref_supplier."'", 'warnings'); + } + } + } + + } + elseif ($user_status_code == "PERMISSION_DENIED") + { + setEventMessage($langs->trans("RemoteUserNotPermission"), 'errors'); + $error_occurred = true; + } + elseif ($user_status_code == "BAD_CREDENTIALS") + { + setEventMessage($langs->trans("RemoteUserBadCredentials"), 'errors'); + $error_occurred = true; + } + else + { + setEventMessage($langs->trans("ResponseNonOK")." '".$user_status_code."'", 'errors'); + $error_occurred = true; + } + + //Form + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($error_occurred) + { + print "
".$langs->trans("ErrorOccurredReviseAndRetry")."
"; + } + else + { + print ''; + print '     '; + } + print ''; + print '
'; + } + } + /* + * Show buttons + */ + else { /** * Boutons actions @@ -1849,6 +2263,13 @@ elseif (! empty($object->id)) //} } + + // Create a remote order using WebService only if module is activated + if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted + { + print ''.$langs->trans('CreateRemoteOrder').''; + } + // Cancel if ($object->statut == 2) { @@ -1975,112 +2396,6 @@ elseif (! empty($object->id)) print ''; } - /* - * Action presend - */ - if ($action == 'presend') - { - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref,'/')); - $file=$fileparams['fullname']; - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - - if (!empty($newlang)) - { - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->load('commercial'); - } - - // Build document if it not exists - if (! $file || ! is_readable($file)) - { - $result= $object->generateDocument(GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref,'/')); - $file=$fileparams['fullname']; - } - - print '
'; - - print_titre($langs->trans('SendOrderByMail')); - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; - $liste=array(); - foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; - $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; - $formmail->withtocc=$liste; - $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); - $formmail->withtopic=$outputlangs->trans('SendOrderRef','__ORDERREF__'); - $formmail->withfile=2; - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__ORDERREF__']=$object->ref; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - //Find the good contact adress - $custcontact=''; - $contactarr=array(); - $contactarr=$object->liste_contact(-1,'external'); - - if (is_array($contactarr) && count($contactarr)>0) { - foreach($contactarr as $contact) { - if ($contact['libelle']==$langs->trans('TypeContact_order_supplier_external_BILLING')) { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $contactstatic=new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact=$contactstatic->getFullName($langs,1); - } - } - - if (!empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__']=$custcontact; - } - } - - // Tableau des parametres complementaires - $formmail->param['action']='send'; - $formmail->param['models']='order_supplier_send'; - $formmail->param['orderid']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - // Init list of files - if (GETPOST("mode")=='init') - { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); - } - - // Show form - print $formmail->get_form(); - - print '
'; - } - print ''; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e88b5a37945..b88fd582400 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -903,12 +903,13 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; $actiontypecode='AC_SUP_INV'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 0cacdf1ffae..93aa4df8083 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -1114,3 +1114,6 @@ DELETE FROM llx_menu WHERE module = 'boutique'; -- Add option always editable on extrafield ALTER TABLE llx_extrafields ADD alwayseditable INTEGER DEFAULT 0 AFTER pos; +-- add supplier webservice fields +ALTER TABLE llx_societe ADD webservices_url varchar(255) DEFAULT NULL; +ALTER TABLE llx_societe ADD webservices_key varchar(128) DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 25629424037..7822ed57a09 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -92,4 +92,6 @@ create table llx_societe logo varchar(255), canvas varchar(32), -- type of canvas if used (null by default) import_key varchar(14) -- import key + webservices_url varchar(255), -- supplier webservice url + webservices_key varchar(128), -- supplier webservice key )ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 59b31693b2b..00f7ae43737 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -514,16 +514,16 @@ Module5000Name=Multi-company Module5000Desc=Allows you to manage multiple companies Module6000Name=Workflow Module6000Desc=Workflow management -Module20000Name=Holidays -Module20000Desc=Declare and follow employees holidays +Module20000Name=Leave Requests management +Module20000Desc=Declare and follow employees leaves requests Module39000Name=Product batch Module39000Desc=Batch number, eat-by and sell-by date management on products Module50000Name=PayBox Module50000Desc=Module to offer an online payment page by credit card with PayBox Module50100Name=Point of sales Module50100Desc=Point of sales module -Module50200Name= Paypal -Module50200Desc= Module to offer an online payment page by credit card with Paypal +Module50200Name=Paypal +Module50200Desc=Module to offer an online payment page by credit card with Paypal Module50400Name=Accounting (advanced) Module50400Desc=Accounting management (double parties) Module54000Name=PrintIPP diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index c25abf6449c..698d34eb539 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -52,16 +52,16 @@ UpdateButtonCP=Update CantUpdate=You cannot update this leave request. NoDateDebut=You must select a start date. NoDateFin=You must select an end date. -ErrorDureeCP=Your request for holidays does not contain working day. -TitleValidCP=Approve the request holidays +ErrorDureeCP=Your leave request does not contain working day. +TitleValidCP=Approve the leave request ConfirmValidCP=Are you sure you want to approve the leave request? DateValidCP=Date approved TitleToValidCP=Send leave request ConfirmToValidCP=Are you sure you want to send the leave request? -TitleRefuseCP=Refuse the request holidays +TitleRefuseCP=Refuse the leave request ConfirmRefuseCP=Are you sure you want to refuse the leave request? NoMotifRefuseCP=You must choose a reason for refusing the request. -TitleCancelCP=Cancel the request holidays +TitleCancelCP=Cancel the leave request ConfirmCancelCP=Are you sure you want to cancel the leave request? DetailRefusCP=Reason for refusal DateRefusCP=Date of refusal @@ -78,7 +78,7 @@ ActionByCP=Performed by UserUpdateCP=For the user PrevSoldeCP=Previous Balance NewSoldeCP=New Balance -alreadyCPexist=A request for holidays has already been done on this period. +alreadyCPexist=A leave request has already been done on this period. UserName=Name Employee=Employee FirstDayOfHoliday=First day of vacation @@ -88,25 +88,25 @@ ManualUpdate=Manual update HolidaysCancelation=Leave request cancelation ## Configuration du Module ## -ConfCP=Configuration of holidays module +ConfCP=Configuration of leave request module DescOptionCP=Description of the option ValueOptionCP=Value -GroupToValidateCP=Group with the ability to approve vacation +GroupToValidateCP=Group with the ability to approve leave requests ConfirmConfigCP=Validate the configuration -LastUpdateCP=Last automatic update of vacation +LastUpdateCP=Last automatic update of leaves allocation UpdateConfCPOK=Updated successfully. ErrorUpdateConfCP=An error occurred during the update, please try again. -AddCPforUsers=Please add the balance of holidays of users by clicking here. -DelayForSubmitCP=Deadline to apply for holidays -AlertapprobatortorDelayCP=Prevent the approbator if the holiday request does not match the deadline +AddCPforUsers=Please add the balance of leaves allocation of users by clicking here. +DelayForSubmitCP=Deadline to make a leave requests +AlertapprobatortorDelayCP=Prevent the approbator if the leave request does not match the deadline AlertValidatorDelayCP=Préevent the approbator if the leave request exceed delay AlertValidorSoldeCP=Prevent the approbator if the leave request exceed the balance nbUserCP=Number of users supported in the module Leaves -nbHolidayDeductedCP=Number of holidays to be deducted per day of vacation taken -nbHolidayEveryMonthCP=Number of vacation days added every month +nbHolidayDeductedCP=Number of leave days to be deducted per day of vacation taken +nbHolidayEveryMonthCP=Number of leave days added every month Module27130Name= Management of leave requests Module27130Desc= Management of leave requests -TitleOptionMainCP=Main settings of Leave request +TitleOptionMainCP=Main settings of leave request TitleOptionEventCP=Settings of leave requets for events ValidEventCP=Validate UpdateEventCP=Update events diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 54e0edbf76a..e95ec86066c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -334,6 +334,18 @@ class Societe extends CommonObject */ var $import_key; + /** + * Supplier WebServices URL + * @var string + */ + var $webservices_url; + + /** + * Supplier WebServices Key + * @var string + */ + var $webservices_key; + var $logo; var $logo_small; var $logo_mini; @@ -715,6 +727,10 @@ class Societe extends CommonObject $supplier=true; } + //Web services + $this->webservices_url = $this->webservices_url?clean_url($this->webservices_url,0):''; + $this->webservices_key = trim($this->webservices_key); + $this->db->begin(); // Check name is required and codes are ok or unique. @@ -795,6 +811,9 @@ class Societe extends CommonObject $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->default_lang."'":"null"); $sql .= ",logo = ".(! empty($this->logo)?"'".$this->logo."'":"null"); + $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); + $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); + if ($customer) { $sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null"); @@ -951,6 +970,7 @@ class Societe extends CommonObject $sql .= ', s.fk_typent as typent_id'; $sql .= ', s.fk_effectif as effectif_id'; $sql .= ', s.fk_forme_juridique as forme_juridique_code'; + $sql .= ', s.webservices_url, s.webservices_key'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; @@ -1086,6 +1106,9 @@ class Societe extends CommonObject $this->default_lang = $obj->default_lang; $this->logo = $obj->logo; + $this->webservices_url = $obj->webservices_url; + $this->webservices_key = $obj->webservices_key; + $this->outstanding_limit = $obj->outstanding_limit; // multiprix diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 795e8fe5cd5..54effb54b20 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -119,7 +119,7 @@ if (empty($reshook)) $res=$object->setValueFrom('localtax2_value', $value); } - // Add new third party + // Add new or update third party if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) { @@ -189,6 +189,10 @@ if (empty($reshook)) $object->commercial_id = GETPOST('commercial_id', 'int'); $object->default_lang = GETPOST('default_lang'); + // Webservices url/key + $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); + $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -217,6 +221,18 @@ if (empty($reshook)) $error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled"); $action = ($action=='add'?'create':'edit'); } + if (! empty($object->webservices_url)) { + //Check if has transport, without any the soap client will give error + if (strpos($object->webservices_url, "http") === false) + { + $object->webservices_url = "http://".$object->webservices_url; + } + if (! isValidUrl($object->webservices_url)) { + $langs->load("errors"); + $error++; $errors[] = $langs->trans("ErrorBadUrl",$object->webservices_url); + $action = ($action=='add'?'create':'edit'); + } + } // We set country_id, country_code and country for the selected country $object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id; @@ -1179,6 +1195,10 @@ else $object->tva_intra = GETPOST('tva_intra', 'alpha'); $object->status = GETPOST('status', 'int'); + // Webservices url/key + $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); + $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); + //Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value'); $object->localtax2_assuj = GETPOST('localtax2assuj_value'); @@ -1558,6 +1578,14 @@ else print $object->showOptionals($extrafields,'edit'); } + // Webservices url/key + if (!empty($conf->syncsupplierwebservices->enabled)) { + print ''; + print ''; + print ''; + print ''; + } + // Logo print ''; print ''; @@ -2018,6 +2046,12 @@ else print "\n"; } + // Webservices url/key + if (!empty($conf->syncsupplierwebservices->enabled)) { + print ''.$langs->trans("WebServiceURL").''.dol_print_url($object->webservices_url).''; + print ''.$langs->trans('WebServiceKey').''.$object->webservices_key.''; + } + print ''; dol_fiche_end(); diff --git a/htdocs/theme/eldy/img/background.png b/htdocs/theme/eldy/img/background.png new file mode 100644 index 00000000000..fb63f12299c Binary files /dev/null and b/htdocs/theme/eldy/img/background.png differ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 90826327b59..b8467076f40 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -223,7 +223,6 @@ body { background-color: #FFFFFF; background: ; - /* background-image: url(""); */ color: #101010; font-size: px; @@ -831,10 +830,10 @@ foreach($mainmenuusedarray as $val) .bodylogin { - background: #f0f0f0; - /*-moz-box-shadow: inset 0 0 10px #000000; + background: #fbfbfb; + /* -moz-box-shadow: inset 0 0 10px #000000; -webkit-box-shadow: inset 0 0 10px #000000; - box-shadow: inset 0 0 10px #000000;*/ + box-shadow: inset 0 0 10px #000000; */ } .login_vertical_align { padding: 10px; @@ -861,17 +860,23 @@ form#login { padding-top:12px; padding-bottom:12px; max-width: 540px; - border: 1px solid #A0A0A0; + + border: 1px solid #C0C0C0; + background-color: #E0E0E0; + + -moz-box-shadow: 3px 2px 20px #CCC; + -webkit-box-shadow: 3px 2px 20px #CCC; + box-shadow: 3px 2px 20px #CCC; border-radius: 8px; - border:solid 1px rgba(90,90,90,.4); - -moz-box-shadow: 0 4px 23px 5px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(60,60,60,0.15); - -webkit-box-shadow: 0 4px 23px 5px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(60,60,60,0.15); - box-shadow: 0 4px 23px 5px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(60,60,60,0.15); - - background-color: #FFFFFF; - background: -webkit-gradient(linear, center top, center bottom, color-stop(0%, #fff), color-stop(100%, #f8f8f8)); - background: -moz-linear-gradient(top, #fff, #f8f8f8); + border:solid 1px rgba(128,128,128,.4); + border-top:solid 1px f8f8f8; + background-color: #f8f8f8; + background-image: -o-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%); + background-image: -moz-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%); + background-image: -webkit-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%); + background-image: -ms-linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%); + background-image: linear-gradient(top, rgba(250,250,250,.6) 0%, rgba(192,192,192,.3) 100%); } div#login_left, div#login_right { display: inline-block; diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index 357a09ccdbe..6fbcdb59538 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -71,6 +71,7 @@ $newlangid='en_EN'; // To force a new lang id $filter=array(); $regenerate=''; // Ask regenerate (contains name of model to use) $option=''; +$fileprefix='mergedpdf'; foreach ($argv as $key => $value) { @@ -84,6 +85,13 @@ foreach ($argv as $key => $value) $newlangid=$valarray[1]; print 'Use language '.$newlangid.".\n"; } + if (preg_match('/^prefix=/i',$value)) + { + $found=true; + $valarray=explode('=',$value); + $fileprefix=$valarray[1]; + print 'Use prefix for filename '.$fileprefix.".\n"; + } if (preg_match('/^regenerate=(.*)/i',$value,$reg)) { @@ -232,7 +240,7 @@ if (in_array('bank',$filter) && in_array('nopayment',$filter)) // Define SQL and SQL request to select invoices // Use $filter, $dateafterdate, datebeforedate, $paymentdateafter, $paymentdatebefore -$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, $paymentonbankid, $thirdpartiesid); +$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, $paymentonbankid, $thirdpartiesid, $fileprefix); @@ -283,6 +291,7 @@ function usage() print "To limit to some thirdparties, use filter=onlythirdparties id1,id2...\n"; print "To regenerate existing PDF, use regenerate=crabe\n"; print "To generate invoices in a language, use lang=xx_XX\n"; + print "To set prefix of generated file name, use prefix=myfileprefix\n"; print "\n"; print "Example: ".$script_file." filter=payments 20080101 20081231 lang=fr_FR regenerate=crabe\n"; print "Example: ".$script_file." filter=all lang=en_US\n";