diff --git a/ChangeLog b/ChangeLog index 69005b0c492..1235a85e097 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,9 +11,10 @@ NEW: complete_head_from_modules() in ldap_prepare_head() WARNING: -Following changes may create regression for some external modules, but were necessary to make Dolibarr better: +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The methode "cloture" on contact were renamed into "closeAll". - +* The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__, + __PROPALREF__, ...) ***** ChangeLog for 6.0.0 compared to 5.0.* ***** diff --git a/build/makepack-dolibarrmodule.pl b/build/makepack-dolibarrmodule.pl index 62002fd063b..4a9a217b570 100755 --- a/build/makepack-dolibarrmodule.pl +++ b/build/makepack-dolibarrmodule.pl @@ -3,6 +3,7 @@ # \file build/makepack-dolibarrmodule.pl # \brief Package builder (tgz, zip, rpm, deb, exe) # \author (c)2005-2014 Laurent Destailleur +# \contributor (c)2017 Nicolas ZABOURI #---------------------------------------------------------------------------- use Cwd; @@ -134,7 +135,15 @@ foreach my $PROJECT (@PROJECTLIST) { # Get version $MAJOR, $MINOR and $BUILD print "Version detected for module ".$PROJECT.": "; $result=open(IN,"<".$SOURCE."/htdocs/".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php"); - if (! $result) { die "Error: Can't open descriptor file ".$SOURCE."/htdocs/".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php for reading.\n"; } + $custom=false; + if (! $result) { + $result=open(IN,"<".$SOURCE."/htdocs/custom/".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php"); + if (! $result) { + die "Error: Can't open descriptor file ".$SOURCE."/htdocs/(or /htdocs/custom/)".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php for reading.\n"; + }else{ + $custom = true; + } + } while() { if ($_ =~ /this->version\s*=\s*'([\d\.]+)'/) { $PROJVERSION=$1; break; } @@ -294,8 +303,11 @@ foreach my $PROJECT (@PROJECTLIST) { $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf.php.old`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf.php.postgres`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf*sav*`; + if($custom){ + $ret=`cp -r $BUILDROOT/$PROJECTLC/htdocs/custom/* $BUILDROOT/$PROJECTLC/htdocs/.`; + } $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom`; - $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom2`; + $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom2`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/test`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/Thumbs.db $BUILDROOT/$PROJECTLC/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/*/*/Thumbs.db`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/CVS* $BUILDROOT/$PROJECTLC/*/CVS* $BUILDROOT/$PROJECTLC/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/*/*/CVS*`; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 9df72687da8..5c17f07183e 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -289,7 +289,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) @@ -740,15 +740,6 @@ if ($id) print ''; print ""; - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates') - { - print '* '.$langs->trans("AvailableVariables").": "; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $tmp=FormMail::getAvailableSubstitKey('formemail'); - print implode(', ', $tmp); - print ''; - } - $colspan=count($fieldlist)+3; if ($id == 4) $colspan++; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index fbacabda5d1..53569c50b00 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -185,7 +185,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } if (isset($_POST["country"]) && ($_POST["country"] <= 0)) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index fd988f9c637..2271fa73c0b 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -174,7 +174,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 2e125925860..efc3d7f0eaa 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -209,7 +209,7 @@ print '
' . $langs->trans("ViewFlatList") . ''; -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,$viewflat,'',$limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'title_accountancy',0,$viewflat,'', $limit); // Reverse sort order if ( preg_match('/^asc/i', $sortorder) ) @@ -315,7 +315,7 @@ while ($i < min($num, $limit)) // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' : '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')'; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' : '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')'; print '' . ($line->debit ? price($line->debit) :''). ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index ee17976ca30..c7ebb5ed5af 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -114,11 +114,11 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', } // Mass actions -$objectclass='Skeleton'; -$objectlabel='Skeleton'; -$permtoread = $user->rights->accounting->read; -$permtodelete = $user->rights->accounting->delete; -$uploaddir = $conf->accounting->dir_output; +$objectclass='ExpenseReport'; +$objectlabel='ExpenseReport'; +$permtoread = $user->rights->expensereport->read; +$permtodelete = $user->rights->expensereport->delete; +$uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($massaction == 'ventil') { diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index db4c631c0c9..be11b08c9ee 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -68,6 +68,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid; if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'"; $sql.= " ORDER BY d.rowid ASC"; @@ -123,7 +124,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg { $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; if ($nb <= 0) $nb=1; // Protection to avoid empty page - + for($j=0;$j<$nb;$j++) { $arrayofmembers[]=array( diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index fa2c11849fb..50676e4c3af 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -165,6 +165,8 @@ if (! empty($triggers)) if ($module == 'shipping') $module = 'expedition_bon'; if ($module == 'member') $module = 'adherent'; if ($module == 'project') $module = 'projet'; + if ($module == 'proposal_supplier') $module = 'supplier_proposal'; + //print 'module='.$module.'
'; if (! empty($conf->$module->enabled)) { diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a5e37f620f7..a999db51857 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -373,11 +373,12 @@ $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AG print ''."\n"; // AGENDA_DEFAULT_FILTER_STATUS +// TODO Remove to use the default generic feature print ''."\n"; print ''.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").''."\n"; print ' '."\n"; print ''."\n"; -$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2); +$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100'); print ''."\n"; // AGENDA_DEFAULT_VIEW diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index c42fd305eba..bf3b2e9ea92 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -399,7 +399,7 @@ print ''; -print '

'; +print '

'; /* diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index 70bf15d03f3..507a6d86f24 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -162,7 +162,7 @@ foreach ($list as $key) print "\n"; -print '

'; +print '

'; print '
'; llxFooter(); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 1b7f2af5a5f..0aa9b5a9e78 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -663,7 +663,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base { $ok = 0; - $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; + $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 85783ae197d..10653df9dc0 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -286,7 +286,7 @@ class PrestaShopWebservice * $xml = $ws->get(array('resource' => 'orders', 'id' => 1)); * // Here in $xml, a SimpleXMLElement object you can parse * foreach ($xml->children()->children() as $attName => $attValue) - * echo $attName.' = '.$attValue.'
'; + * echo $attName.' = '.$attValue.'
'; * } * catch (PrestaShopWebserviceException $ex) * { diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index 8fa25cce1a8..aff21ce58e8 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -40,41 +40,52 @@ class Dolistore /** * Constructor - * - * @param array $options Options */ - function __construct($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + function __construct() { global $conf, $langs; - $this->start = $options['start']; - $this->end = $options['end']; - $this->per_page = $options['per_page']; - $this->categorie = $options['categorie']; - $this->search = $options['search']; - $this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace'; $this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product='; $this->vat_rate = 1.2; // 20% de TVA $this->debug_api = false; - if ($this->end == 0) { + $langtmp = explode('_', $langs->defaultlang); + $lang = $langtmp[0]; + $lang_array = array('en'=>0, 'fr'=>1, 'es'=>2, 'it'=>3, 'de'=>4); // Into table ps_lang of Prestashop - 1 + if (! in_array($lang, array_keys($lang_array))) $lang = 'en'; + $this->lang = $lang_array[$lang]; + } + + /** + * Load data from remote Dolistore market place. + * This fills ->categories + * + * @param array $options Options + * @return void + */ + function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + { + global $conf, $langs; + + $this->start = $options['start']; + $this->end = $options['end']; + $this->per_page = $options['per_page']; + $this->categorie = $options['categorie']; + $this->search = $options['search']; + + if ($this->end == 0) { $this->end = $this->per_page; } - $langtmp = explode('_', $langs->defaultlang); - $lang = $langtmp[0]; - $lang_array = array('fr'=>1, 'en'=>2, 'es'=>3, 'it'=>4, 'de'=>5); - if (! in_array($lang, array_keys($lang_array))) $lang = 'en'; - $this->lang = $lang_array[$lang]; // 1=fr 2=en ... - - try { + try { $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api); // Here we set the option array for the Webservice : we want products resources $opt = array(); $opt['resource'] = 'products'; + // make a search to limit the id returned. if ($this->search != '') { $opt2 = array(); @@ -102,7 +113,9 @@ class Dolistore $opt['sort'] = 'id_desc'; $opt['filter[active]'] = '[1]'; $opt['limit'] = "$this->start,$this->end"; - // Call + // $opt['filter[id]'] contais list of product id that are result of search + + // Call API to get the detail $xml = $this->api->get($opt); $this->products = $xml->products->children(); @@ -124,7 +137,12 @@ class Dolistore } } - + /** + * Return tree of Dolistore categories. $this->categories must have been loaded before. + * + * @param int $parent Id of parent category + * @return string + */ function get_categories($parent = 0) { if (!isset($this->categories)) die('not possible'); diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index c3e8bad9f6d..65363f468e8 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -23,7 +23,7 @@ */ require '../main.inc.php'; - + // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; @@ -47,7 +47,7 @@ $list = array ( /* * Actions */ - + if ($action == 'update') { $error = 0; @@ -99,7 +99,7 @@ foreach ($list as $key) print ''; // Param - $label = $langs->trans($key); + $label = $langs->trans($key); print ''; // Value @@ -120,7 +120,7 @@ print ''; print ''; print "\n"; -print '
'; +print '
'; llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ce67595a0f7..6b7d839592c 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -55,7 +55,7 @@ $options['categorie'] = ((GETPOST('categorie', 'int')?GETPOST('categorie', 'int' $options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0); $options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0); $options['search'] = GETPOST('search_keyword', 'alpha'); -$dolistore = new Dolistore($options); +$dolistore = new Dolistore(); if (! $user->admin) @@ -832,6 +832,10 @@ if ($mode == 'marketplace') if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1) { + // $options is array with filter criterias + //var_dump($options); + $dolistore->getRemoteData($options); + print ''.$langs->trans('DOLISTOREdescriptionLong').'

'; $previouslink = $dolistore->get_previous_link(); diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index c6d00501015..88a91feb083 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -235,7 +235,7 @@ print ''; */ print ''; -print '
'; +print '
'; if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) { @@ -293,7 +293,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) print ''; print ''; - print '
'; + print '
'; } diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 2ef7a500268..3246caeb411 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -233,7 +233,7 @@ foreach ($dirmodels as $reldir) print ''; -print "
"; +print "
"; print load_fiche_titre($langs->trans("OtherOptions"),'',''); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 36a4ec697e6..f7e18851306 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -246,7 +246,7 @@ $found++; /*if (! $found) { - + print ''; print ''.$langs->trans("NoModuleToManageStockDecrease").''; print "\n"; @@ -329,7 +329,7 @@ $found++; /*if (! $found) { - + print ''; print ''.$langs->trans("NoModuleToManageStockIncrease").''; print "\n"; @@ -433,7 +433,7 @@ if ($virtualdiffersfromphysical) } -print '
'; +print '
'; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; @@ -441,7 +441,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''."\n"; print ''; print ''."\n"; - + // Example with a yes / no select print ''; print ''; @@ -454,7 +454,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''; - + // Example with a yes / no select print ''; print ''; @@ -467,7 +467,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''; - + // Example with a yes / no select print ''; print ''; @@ -480,7 +480,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''; - + print '
'.$langs->trans("Inventory").'  
'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").'
'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").'
'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").'
'; } @@ -492,7 +492,7 @@ print "  \n"; print ''."\n"; if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - + print ''; print ''.$langs->trans("UseDispatchStatus").''; print ''; @@ -536,7 +536,7 @@ print '
'; If not used by a module, I still need to understand in which case user may need this now we can set rule on product page. if ($conf->global->PRODUIT_SOUSPRODUITS) { - + print ''; print ''.$langs->trans("IndependantSubProductStock").''; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 9f734c9e24d..2730c6c0242 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -37,6 +37,10 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not lo if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +// Force entity if a value provided int HTTP header. Otherwise, will use the entity of user of token used. +if (! empty($_SERVER['HTTP_DOLAPIENTITY'])) define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']); + + $res=0; if (! $res && file_exists("../main.inc.php")) $res=include '../main.inc.php'; if (! $res) die("Include of main fails"); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b59d47adb9e..cb6da443404 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -851,7 +851,8 @@ class ActionComm extends CommonObject } /** - * Load all objects with filters + * Load all objects with filters. + * WARNING: This make a fetch on all records instead of making one request with a join. * * @param DoliDb $db Database handler * @param int $socid Filter by thirdparty @@ -863,7 +864,7 @@ class ActionComm extends CommonObject * @param string $limit Limit number of answers * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='datep', $sortorder='DESC', $limit=0) + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='a.datep', $sortorder='DESC', $limit=0) { global $conf, $langs; @@ -880,7 +881,7 @@ class ActionComm extends CommonObject } if (! empty($filter)) $sql.= $filter; if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); - if ($limit) $sql.=$db->plimit($limit); + $sql.=$db->plimit($limit, 0); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index c77c4279439..78e73fe0717 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -371,6 +371,7 @@ if ($resql) print ''; print ''; + print ''; print ''; print ''; print ''; @@ -382,7 +383,6 @@ if ($resql) print ''; print ''; if (! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) print ''; - print ''; print ''; print $formactions->form_select_status_action('formaction',$status,1,'status',1,2); print ''; @@ -395,7 +395,8 @@ if ($resql) print ''; print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Title",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("ActionsOwnedByShort",$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder); print_liste_field_titre("DateStart",$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder); @@ -403,7 +404,6 @@ if ($resql) print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre("Contact",$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); if (! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) print_liste_field_titre("LinkedObject",$_SERVER["PHP_SELF"],"a.fk_element",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("ActionsOwnedByShort",$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre(""); print "\n"; @@ -437,13 +437,23 @@ if ($resql) print ''; - // Action (type) + // Ref print ''; print $actionstatic->getNomUrl(1,-1); print ''; - // Action (type) - print ''; + // User owner + print ''; + if ($obj->fk_user_action > 0) + { + $userstatic->fetch($obj->fk_user_action); + print $userstatic->getNomUrl(-1); + } + else print ' '; + print ''; + + // Label + print ''; print $actionstatic->label; print ''; @@ -482,7 +492,7 @@ if ($resql) print ''; // Third party - print ''; + print ''; if ($obj->socid) { $societestatic->id=$obj->socid; @@ -520,16 +530,6 @@ if ($resql) print ''; } - // User owner - print ''; - if ($obj->fk_user_action > 0) - { - $userstatic->fetch($obj->fk_user_action); - print $userstatic->getNomUrl(-1); - } - else print ' '; - print ''; - // Status/Percent $datep=$db->jdate($obj->datep); print ''.$actionstatic->LibStatut($obj->percent,3,0,$datep).''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b2b7e9cf5cf..c40192723a8 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1224,7 +1224,6 @@ else // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic'); - dol_fiche_head(null, '', '', -1); print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 9669d8c0ff3..5a5ef5fa90c 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -425,7 +425,7 @@ if ($object->fetch($id) >= 0) if ($allowaddtarget) { $cleartext=$langs->trans("ToClearAllRecipientsClickHere").' '.'id.'" class="button reposition">'.$langs->trans("TargetsReset").''; } - print_barre_liste($langs->trans("MailSelectedRecipients"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$cleartext,$num,$nbtotalofrecords,'title_generic',0,'','',$limit); + print_barre_liste($langs->trans("MailSelectedRecipients"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$cleartext,$num,$nbtotalofrecords,'title_generic',0,'','', $limit); print ''; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7987555e569..8fb2a102c22 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -125,7 +125,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action = ''; + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -611,7 +619,7 @@ if (empty($reshook)) // prevent browser refresh from closing proposal several times if ($object->statut == Propal::STATUS_VALIDATED) { - $result=$object->cloture($user, GETPOST('statut'), GETPOST('note')); + $result=$object->cloture($user, GETPOST('statut','int'), GETPOST('note_private','alpha')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -638,16 +646,10 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - - /* - * Send mail - */ - // Actions to send emails $actiontypecode='AC_OTH_AUTO'; $trigger_name='PROPAL_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromproposal'; + $autocopy='MAIN_MAIL_AUTOCOPY_PROPOSAL_TO'; $trackid='pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -1686,6 +1688,18 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ClonePropal'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } + if ($action == 'statut') + { + //Form to close proposal (signed or not) + $formquestion = array( + array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->labelstatut [2],3=>$object->labelstatut [3])), + //array('type' => 'other','name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '')); + array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => $object->note_private)); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), '', 'setstatut', $formquestion, '', 1, 250); + + } + // Confirm delete else if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); @@ -2213,35 +2227,6 @@ if ($action == 'create') dol_fiche_end(); - if ($action == 'statut') - { - /* - * Form to close proposal (signed or not) - */ - $form_close = ''; - $form_close .= ''; - $form_close .= '
'; - $form_close .= ''; - $form_close .= ''; - $form_close .= ''; - $form_close .= '
' . $langs->trans("CloseAs") . ''; - $form_close .= ''; - $form_close .= ''; - $form_close .= '
' . $langs->trans('Note') . '
'; - $form_close .= ''; - $form_close .= '   '; - $form_close .= ' '; - $form_close .= '
'; - - print $form_close; - } - /* * Boutons Actions */ @@ -2253,7 +2238,7 @@ if ($action == 'create') // modified by hook if (empty($reshook)) { - if ($action != 'statut' && $action != 'editline') + if ($action != 'editline') { // Validate if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0) @@ -2378,123 +2363,13 @@ if ($action == 'create') print ''; } - /* - * Action presend - */ - if ($action == 'presend') - { - $object->fetch_projet(); + // Presend form + $modelmail='propal_send'; + $defaulttopic='SendPropalRef'; + $diroutput = $conf->propal->dir_output; + $trackid = 'pro'.$object->id; - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->propal->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->thirdparty->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, $object->error, $object->errors); - exit(); - } - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - } - - print '
'; - print '
'; - print '
'; - print load_fiche_titre($langs->trans('SendPropalByMail')); - - dol_fiche_head(''); - - // Create form object - 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 = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - $formmail->trackid='pro'.$object->id; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'pro'.$object->id); - } - $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); - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__ (__REFCLIENT__)'); - } - $formmail->withfile = 2; - $formmail->withbody = 1; - $formmail->withdeliveryreceipt = 1; - $formmail->withcancel = 1; - - // Tableau des substitutions - $formmail->setSubstitFromObject($object); - $formmail->substit['__PROPREF__'] = $object->ref; // For backward compatibility - - // 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_propal_external_CUSTOMER')) { // TODO Use code and not label - $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'] = 'propal_send'; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id'] = $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)); - } - - print $formmail->get_form(); - - dol_fiche_end(); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 909b0f3ebc8..41002eb9e71 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -96,8 +96,8 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='p.ref'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='proposallist'; +// Initialize technical object to manage context to save list fields +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'proposallist'; // Security check $module='propal'; @@ -238,7 +238,7 @@ llxHeader('',$langs->trans('Proposal'),$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' p.rowid, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; @@ -413,105 +413,18 @@ if ($resql) print ''; print ''; print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); if ($massaction == 'presend') { - $langs->load("mails"); - - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new Propal($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', ''); - $topicmail="SendSupplierProposalRef"; $modelmail="supplier_proposal_send"; + $objecttmp=new Propal($db); + $trackid='ord'.$object->id; - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='ord'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } if ($sall) @@ -813,6 +726,7 @@ if ($resql) $companystatic->name=$obj->name; $companystatic->client=$obj->client; $companystatic->code_client=$obj->code_client; + $companystatic->email=$obj->email; // Thirdparty if (! empty($arrayfields['s.nom']['checked'])) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 040b1e200d8..4c49cef6820 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -118,16 +118,11 @@ if (empty($reshook)) { if ($cancel) { - if ($action != 'addlink' && $action != 'updateline') + if (! empty($backtopage)) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/commande/list.php',1); - header("Location: ".$urltogo); + header("Location: ".$backtopage); exit; } - if ($id > 0 || ! empty($ref)) { - $ret = $object->fetch($id,$ref); - $object->fetch_thirdparty(); - } $action=''; } @@ -1256,13 +1251,13 @@ if (empty($reshook)) exit(); } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails $trigger_name='ORDER_SENTBYMAIL'; $paramname='id'; - $mode='emailfromorder'; + $autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add $trackid='ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -2596,134 +2591,13 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } - /* - * Action presend - */ - if ($action == 'presend') - { - $object->fetch_projet(); + // Presend form + $modelmail='order_send'; + $defaulttopic='SendOrderRef'; + $diroutput = $conf->commande->dir_output; + $trackid = 'ord'.$object->id; - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->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->thirdparty->default_lang; - - if (!empty($newlang)) - { - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->load('commercial'); - } - - // Show email form - - // By default if $action=='presend' - $titreform='SendOrderByMail'; - $topicmail=''; - if (empty($object->ref_client)) { - $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); - } else if (! empty($object->ref_client)) { - $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); - } - $action='send'; - $modelmail='order_send'; - - // 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, $object->error, $object->errors); - exit(); - } - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - } - - print '
'; - print '
'; - print '
'; - print load_fiche_titre($langs->trans($titreform)); - - dol_fiche_head(''); - - // 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 = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - $formmail->trackid='ord'.$object->id; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $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 = $conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic = $topicmail; - $formmail->withfile = 2; - $formmail->withbody = 1; - $formmail->withdeliveryreceipt = 1; - $formmail->withcancel = 1; - // Tableau des substitutions - $formmail->setSubstitFromObject($object); - $formmail->substit ['__ORDERREF__'] = $object->ref; - - $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_commande_external_CUSTOMER')) { // TODO Use code and not label - $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'] = $action; - $formmail->param['models'] = $modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $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(); - - dol_fiche_end(); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 13841b108d9..927460c511a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -42,6 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->loadLangs(array("orders",'sendings','deliveries','companies','compta','bills')); @@ -82,6 +83,7 @@ $result = restrictedArea($user, 'commande', $id,''); $diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id; +// Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -118,7 +120,8 @@ $checkedtypetiers=0; $arrayfields=array( 'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'c.ref_client'=>array('label'=>$langs->trans("RefCustomerOrder"), 'checked'=>1), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), + 'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), @@ -186,6 +189,7 @@ if (empty($reshook)) $search_deliveryday=''; $search_deliverymonth=''; $search_deliveryyear=''; + $search_project_ref=''; $viewstatut=''; $billed=''; $toselect=''; @@ -203,7 +207,8 @@ if (empty($reshook)) $permtoread = $user->rights->commande->lire; $permtodelete = $user->rights->commande->supprimer; $uploaddir = $conf->commande->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + $trigger_name='ORDER_SENTBYMAIL'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // TODO Move this into mass action include if ($massaction == 'confirm_createbills') { @@ -438,6 +443,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $companystatic = new Societe($db); $formcompany=new FormCompany($db); +$projectstatic=new Project($db); $title=$langs->trans("Orders"); $help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; @@ -445,12 +451,13 @@ llxHeader('',$title,$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; $sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; -$sql.= ' c.date_creation as date_creation, c.tms as date_update'; +$sql.= ' c.date_creation as date_creation, c.tms as date_update,'; +$sql.= " p.rowid as project_id, p.ref as project_ref"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -465,6 +472,7 @@ $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) @@ -539,6 +547,7 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1); +if ($search_project_ref != '') $sql.= natural_search("p.ref",$search_project_ref); // Add where from extra fields foreach ($search_array_options as $key => $val) { @@ -626,7 +635,8 @@ if ($resql) if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht; if ($search_total_vat != '') $param.='&search_total_vat='.$search_total_vat; if ($search_total_ttc != '') $param.='&search_total_ttc='.$search_total_ttc; - if ($show_files) $param.='&show_files=' .$show_files; + if ($search_project_ref >= 0) $param.="&search_project_ref=".$search_project_ref; + if ($show_files) $param.='&show_files=' .$show_files; if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($billed != '') $param.='&billed='.$billed; // Add $param from extra fields @@ -661,102 +671,17 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); - // TODO Move this into an invluce if ($massaction == 'presend') { - $langs->load("mails"); + $topicmail="SendOrderRef"; + $modelmail="order_send"; + $objecttmp=new Commande($db); + $trackid='ord'.$object->id; - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new Commande($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - dol_fiche_head(null, '', ''); - - $topicmail="SendOrderRef"; - $modelmail="order_send"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='ord'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } - elseif ($massaction == 'createbills') + + if ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; @@ -873,6 +798,11 @@ if ($resql) print ''; print ''; } + // Project ref + if (! empty($arrayfields['p.project_ref']['checked'])) + { + print ''; + } // Thirpdarty if (! empty($arrayfields['s.nom']['checked'])) { @@ -1016,6 +946,7 @@ if ($resql) print ''; if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'],$_SERVER["PHP_SELF"],'c.ref','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'],$_SERVER["PHP_SELF"],'c.ref_client','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder); @@ -1065,27 +996,35 @@ if ($resql) { $obj = $db->fetch_object($resql); - print ''; - $notshippable=0; $warning = 0; $text_info=''; $text_warning=''; $nbprod=0; + $companystatic->id=$obj->socid; + $companystatic->code_client = $obj->code_client; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->email=$obj->email; + + $generic_commande->id=$obj->rowid; + $generic_commande->ref=$obj->ref; + $generic_commande->statut = $obj->fk_statut; + $generic_commande->date_commande = $db->jdate($obj->date_commande); + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); + $generic_commande->ref_client = $obj->ref_client; + $generic_commande->total_ht = $obj->total_ht; + $generic_commande->total_tva = $obj->total_tva; + $generic_commande->total_ttc = $obj->total_ttc; + + print ''; + // Ref if (! empty($arrayfields['c.ref']['checked'])) { print ''; - $generic_commande->id=$obj->rowid; - $generic_commande->ref=$obj->ref; - $generic_commande->statut = $obj->fk_statut; - $generic_commande->date_commande = $db->jdate($obj->date_commande); - $generic_commande->date_livraison = $db->jdate($obj->date_delivery); - $generic_commande->ref_client = $obj->ref_client; - $generic_commande->total_ht = $obj->total_ht; - $generic_commande->total_tva = $obj->total_tva; - $generic_commande->total_ttc = $obj->total_ttc; + $generic_commande->lines=array(); $generic_commande->getLinesArray(); @@ -1230,10 +1169,16 @@ if ($resql) if (! $i) $totalarray['nbfield']++; } - $companystatic->id=$obj->socid; - $companystatic->code_client = $obj->code_client; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + // Project + if (! empty($arrayfields['p.project_ref']['checked'])) + { + $projectstatic->id=$obj->project_id; + $projectstatic->ref=$obj->project_ref; + print ''; + if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); + print ''; + if (! $i) $totalarray['nbfield']++; + } // Third party if (! empty($arrayfields['s.nom']['checked'])) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 7c94e03e339..b32d4ea938e 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -145,7 +145,7 @@ if ($action == 'add') if ($id > 0) { // Category association - $categories = GETPOST('categories'); + $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $_GET["id"]=$id; // Force chargement page en mode visu @@ -239,7 +239,7 @@ if ($action == 'update') if ($result >= 0) { // Category association - $categories = GETPOST('categories'); + $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 56fb9c90278..9be1aab246b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1256,6 +1256,7 @@ class Account extends CommonObject $label = '' . $langs->trans("ShowAccount") . ''; $label .= '
' . $langs->trans('BankAccount') . ': ' . $this->label; $label .= '
' . $langs->trans('AccountNumber') . ': ' . $this->number; + $label .= '
' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code; if (! empty($conf->accounting->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index db8c2a0f071..e68119a1be8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -132,7 +132,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action=''; + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -1961,20 +1969,17 @@ if (empty($reshook)) exit(); } - - /* - * Send mail - */ + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails if (empty($id)) $id=$facid; $trigger_name='BILL_SENTBYMAIL'; $paramname='id'; - $mode='emailfrominvoice'; + $autocopy='MAIN_MAIL_AUTOCOPY_INVOICE_TO'; $trackid='inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - // Actions to build doc $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; @@ -2007,8 +2012,6 @@ if (empty($reshook)) $action = 'edit_extras'; } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { if ($action == 'addcontact') { $result = $object->fetch($id); @@ -4340,143 +4343,15 @@ else if ($id > 0 || ! empty($ref)) print ''; } - else - { - /* - * Action presend (or prerelance) - */ - $object->fetch_projet(); - // By default if $action=='presend' - $titreform = 'SendBillByMail'; - $topicmail = 'SendBillRef'; - $modelmail = 'facture_send'; + // Presend form + $modelmail='facture_send'; + $defaulttopic='SendBillRef'; + $diroutput = $conf->facture->dir_output; + $trackid = 'inv'.$object->id; - if ($action == 'prerelance') // For backward compatibility - { - $titrefrom = 'SendReminderBillByMail'; - $topicmail = 'SendReminderBillRef'; - $modelmail = 'facture_relance'; - $action = 'relance'; - } else - $action = 'send'; - - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->facture->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->thirdparty->default_lang; - - if (!empty($newlang)) - { - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->load('bills'); - } - - // Build document if it not exists - if (! $file || ! is_readable($file)) { - $result = $object->generateDocument(GETPOST('model','alpha') ? GETPOST('model','alpha') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) { - dol_print_error($db, $object->error, $object->errors); - exit(); - } - $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - } - - print '
'; - print '
'; - print '
'; - print load_fiche_titre($langs->trans($titreform)); - - // Cree l'objet formulaire mail - dol_fiche_head(); - - 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 = (GETPOST('fromtype','alpha')?GETPOST('fromtype','alpha'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - $formmail->trackid='inv'.$object->id; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'inv'.$object->id); - } - $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; // List suggested for send to - $formmail->withtocc = $liste; // List suggested for CC - $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->transnoentities($topicmail, '__REF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->transnoentities($topicmail, '__REF__ (__REFCLIENT__)'); - } - - $formmail->withfile = 2; - $formmail->withbody = 1; - $formmail->withdeliveryreceipt = 1; - $formmail->withcancel = 1; - // Tableau des substitutions - $formmail->setSubstitFromObject($object, $outputlangs); - $formmail->substit['__INVREF__'] = $object->ref; - - // 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_facture_external_BILLING')) { // TODO Use code and not label - - 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 du post - $formmail->param['action'] = $action; - $formmail->param['models'] = $modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['facid'] = $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)); - } - - print $formmail->get_form(); - - dol_fiche_end(); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } llxFooter(); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 98fc2cd2f62..2e7a46f3067 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1122,7 +1122,7 @@ if ($action == 'create') $disableedit=1; $disablemove=1; $disableremove=1; - $ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } print "\n"; @@ -1541,7 +1541,7 @@ else { //$disableedit=1; //$disablemove=1; - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line @@ -1552,7 +1552,7 @@ else $var = true; // Add free products/services - $object->formAddObjectLine(0, $mysoc, $soc); // No date selector for template invoice + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1731,7 +1731,7 @@ else print ''; print ''; - print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); + print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit); print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 15a79d7fdd9..5a59b61e8a3 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -110,8 +110,8 @@ if (! $sortfield) $sortfield='f.datef'; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='invoicelist'; +// Initialize technical object to manage context to save list fields +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicelist'; // Security check $fieldid = (! empty($ref)?'facnumber':'rowid'); @@ -345,6 +345,7 @@ $formfile = new FormFile($db); $bankaccountstatic=new Account($db); $facturestatic=new Facture($db); $formcompany=new FormCompany($db); +$thirdpartystatic=new Societe($db); llxHeader('',$langs->trans('CustomersInvoices'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); @@ -355,7 +356,7 @@ $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; $sql.= ' f.datec as date_creation, f.tms as date_update,'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) @@ -493,7 +494,7 @@ if (! $sall) $sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.paye, f.fk_statut,'; $sql.= ' f.datec, f.tms,'; - $sql.= ' s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.code_client, s.client, typent.code,'; + $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.code_client, s.client, typent.code,'; $sql.= ' state.code_departement, state.nom'; foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by @@ -605,106 +606,18 @@ if ($resql) print ''; print ''; print ''; + print ''; print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); if ($massaction == 'presend') { - $langs->load("mails"); - - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new Facture($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', ''); - $topicmail="SendBillRef"; $modelmail="facture_send"; + $objecttmp=new Facture($db); + $trackid='inv'.$object->id; - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='inv'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'inv'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['facid']=join(',',$arrayofselected); - // TODO We should use $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } if ($sall) @@ -1099,12 +1012,12 @@ if ($resql) if (! empty($arrayfields['s.nom']['checked'])) { print ''; - $thirdparty=new Societe($db); - $thirdparty->id=$obj->socid; - $thirdparty->name=$obj->name; - $thirdparty->client=$obj->client; - $thirdparty->code_client=$obj->code_client; - print $thirdparty->getNomUrl(1,'customer'); + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->name=$obj->name; + $thirdpartystatic->client=$obj->client; + $thirdpartystatic->code_client=$obj->code_client; + $thirdpartystatic->email=$obj->email; + print $thirdpartystatic->getNomUrl(1,'customer'); print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index a193cb1bff1..f2b8cb26cdf 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -507,12 +507,12 @@ class Paiement extends CommonObject /** - * Add a record into bank for payment with links between this bank record and invoices of payment. + * Add a record into bank for payment + links between this bank record and sources of payment. * All payment properties (this->amount, this->amounts, ...) must have been set first like after a call to create(). * * @param User $user Object of user making payment * @param string $mode 'payment', 'payment_supplier' - * @param string $label Label to use in bank record + * @param string $label Label to use in bank record. Note: If label is '(WithdrawalPayment)', a third entry 'widthdraw' is added into bank_url. * @param int $accountid Id of bank account to do link with * @param string $emetteur_nom Name of transmitter * @param string $emetteur_banque Name of bank @@ -596,10 +596,11 @@ class Paiement extends CommonObject } // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) - if (! $error && $label != '(WithdrawalPayment)') + //if (! $error && $label != '(WithdrawalPayment)') + if (! $error) { $linkaddedforthirdparty=array(); - foreach ($this->amounts as $key => $value) // We should have always same third party but we loop in case of. + foreach ($this->amounts as $key => $value) // We should have invoices always for same third party but we loop in case of. { if ($mode == 'payment') { diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 2a91ae13bfc..32c7b638a46 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -51,6 +51,9 @@ if (! $sortfield) $sortfield="p.datec"; // Get supervariables $statut = GETPOST('statut','int'); $search_ref = GETPOST('search_ref','alpha'); +$search_amount = GETPOST('search_amount','alpha'); + +$bon=new BonPrelevement($db,""); /* @@ -60,6 +63,7 @@ $search_ref = GETPOST('search_ref','alpha'); if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=""; + $search_amount=""; } @@ -69,13 +73,12 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', llxHeader('',$langs->trans("WithdrawalsReceipts")); -$bon=new BonPrelevement($db,""); - $sql = "SELECT p.rowid, p.ref, p.amount, p.statut"; $sql.= ", p.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= " WHERE p.entity = ".$conf->entity; if ($search_ref) $sql.=natural_search("p.ref", $search_ref); +if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1); $sql.= $db->order($sortfield,$sortorder); @@ -97,6 +100,8 @@ if ($result) $urladd= "&statut=".$statut; + $selectedfields=''; + // Lines of title fields print '
'; if ($optioncss != '') print ''; @@ -116,7 +121,9 @@ if ($result) print ''."\n"; print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; - print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"'); - print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"'); - print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"","","",'align="center"'); + print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder); + print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder); + print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder); + print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder); + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print "\n"; while ($i < min($num,$limit)) @@ -136,15 +145,18 @@ if ($result) print '\n"; print '\n"; print '\n"; + print ''; + + print ''."\n"; + print "\n"; $i++; } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 20d7b0232e9..97f5d96903f 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -20,7 +20,7 @@ /** * \file htdocs/compta/prelevement/card.php * \ingroup prelevement - * \brief Fiche prelevement + * \brief Card of a direct debit */ require('../../main.inc.php'); @@ -45,20 +45,24 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $action = GETPOST('action','alpha'); $id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid','int'); - +// Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; + if (! $sortfield) $sortfield='pl.fk_soc'; if (! $sortorder) $sortorder='DESC'; +$object = new BonPrelevement($db,""); + /* * Actions @@ -66,10 +70,9 @@ if (! $sortorder) $sortorder='DESC'; if ( $action == 'confirm_delete' ) { - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); - $res=$bon->delete(); + $res=$object->delete(); if ($res > 0) { header("Location: index.php"); @@ -77,16 +80,16 @@ if ( $action == 'confirm_delete' ) } } +// Seems to no be used and replaced with $action == 'infocredit if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes') { - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); - $res=$bon->set_credite(); + $res=$object->set_credite(); if ($res >= 0) { header("Location: card.php?id=".$id); - exit; + exit; } } @@ -94,19 +97,18 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); /* - if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref) + if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref) { $dir = $conf->prelevement->dir_output.'/receipts'; if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0) { - $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); + $object->set_infotrans($user, $dt, GETPOST('methode','alpha')); } header("Location: card.php?id=".$id); @@ -118,7 +120,7 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) $mesg='BadFile'; }*/ - $error = $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); + $error = $object->set_infotrans($user, $dt, GETPOST('methode','alpha')); if ($error) { @@ -127,13 +129,13 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) } } +// Set direct debit order to credited, create payment and close invoices if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) { - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); - $error = $bon->set_infocredit($user, $dt); + $error = $object->set_infocredit($user, $dt); if ($error) { @@ -143,61 +145,66 @@ if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) } + /* * View */ -$bon = new BonPrelevement($db,""); $form = new Form($db); llxHeader('',$langs->trans("WithdrawalsReceipts")); - -if ($id > 0) +if ($id > 0 || $ref) { - $bon->fetch($id); + $object->fetch($id, $ref); - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); if (GETPOST('error','alpha')!='') { - print '
'.$bon->getErrorString(GETPOST('error','alpha')).'
'; + print '
'.$object->getErrorString(GETPOST('error','alpha')).'
'; } /*if ($action == 'credite') { - print $form->formconfirm("card.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); + print $form->formconfirm("card.php?id=".$object->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); }*/ + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); + + print '
'; + print '
'; print '
  '; $searchpicto=$form->showFilterButtons(); @@ -125,9 +132,11 @@ if ($result) print '
'; - print $bon->LibStatut($obj->statut,2); - print " "; - print ''.$obj->ref."'.dol_print_date($db->jdate($obj->datec),'day')."'.price($obj->amount)."'; + print $bon->LibStatut($obj->statut, 3); + print '
'; - print ''; - print ''; - print ''; + //print ''; + print ''; + print ''; // Status + /* print ''; - print ''; + print ''; print ''; + */ - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -205,19 +212,36 @@ if ($id > 0) print '
'; - print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); - if (empty($bon->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') + if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') { - print ''; + print ''; print ''; print ''; print ''; @@ -227,7 +251,7 @@ if ($id > 0) print $form->select_date('','','','','',"userfile",1,1); print ''; print ''; /* print '
'.$langs->trans("TransMetod").''; - print $form->selectarray("methode",$bon->methodes_trans); + print $form->selectarray("methode",$object->methodes_trans); print '
'.$langs->trans("File").''; print ''; @@ -238,9 +262,9 @@ if ($id > 0) print ''; } - if (! empty($bon->date_trans) && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') + if (! empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') { - print '
'; + print ''; print ''; print ''; print ''; @@ -261,17 +285,17 @@ if ($id > 0) { print "\n
\n"; - if (empty($bon->date_trans) && $user->rights->prelevement->bons->send) + if (empty($object->date_trans) && $user->rights->prelevement->bons->send) { - print "id."\">".$langs->trans("SetToStatusSent").""; + print "id."\">".$langs->trans("SetToStatusSent").""; } - if (! empty($bon->date_trans) && $bon->date_credit == 0) + if (! empty($object->date_trans) && $object->date_credit == 0) { - print "id."\">".$langs->trans("ClassCredited").""; + print "id."\">".$langs->trans("ClassCredited").""; } - print "id."\">".$langs->trans("Delete").""; + print "id."\">".$langs->trans("Delete").""; print "
"; } @@ -293,7 +317,16 @@ if ($id > 0) $sql.= " AND pl.fk_soc = s.rowid"; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit+1, $offset); + + // Count total nb of records + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + + $sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); @@ -304,8 +337,9 @@ if ($id > 0) $urladd = "&id=".$id; - print_barre_liste("", $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); - print"\n\n"; + print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; print ''; print_liste_field_titre("Lines",$_SERVER["PHP_SELF"],"pl.rowid",'',$urladd); @@ -363,12 +397,17 @@ if ($id > 0) print ''; print ''; print ''; - print '\n"; + print '\n"; print ''; print "\n"; } print "
'.$langs->trans("Total").' '.price($total)."'; + if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + print price($total); + print " 
"; + print ''; + $db->free($result); } else diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index ab04278ea84..0278d97d724 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -38,6 +38,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; */ class BonPrelevement extends CommonObject { + public $element='widthdraw'; + public $table_element='prelevement_bons'; + public $picto = 'payment'; + var $date_echeance; var $raison_sociale; var $reference_remise; @@ -263,10 +267,11 @@ class BonPrelevement extends CommonObject /** * Get object and lines from database * - * @param int $rowid id of object to load + * @param int $rowid Id of object to load + * @param string $ref Ref of direct debit * @return int >0 if OK, <0 if KO */ - function fetch($rowid) + function fetch($rowid, $ref='') { global $conf; @@ -278,8 +283,9 @@ class BonPrelevement extends CommonObject $sql.= ", p.fk_user_credit"; $sql.= ", p.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql.= " WHERE p.rowid = ".$rowid; - $sql.= " AND p.entity = ".$conf->entity; + $sql.= " WHERE p.entity = ".$conf->entity; + if ($rowid > 0) $sql.= " AND p.rowid = ".$rowid; + else $sql.= " AND p.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result=$this->db->query($sql); @@ -321,7 +327,7 @@ class BonPrelevement extends CommonObject } /** - * Set credite and set status of linked invoices + * Set credite and set status of linked invoices. Still used ?? * * @return int <0 if KO, >=0 if OK */ @@ -345,7 +351,7 @@ class BonPrelevement extends CommonObject $error++; } - if ($error == 0) + if (! $error) { $facs = array(); $facs = $this->getListInvoices(); @@ -361,9 +367,8 @@ class BonPrelevement extends CommonObject } } - if ($error == 0) + if (! $error) { - $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql.= " SET statut = 2"; $sql.= " WHERE fk_prelevement_bons = ".$this->id; @@ -378,7 +383,7 @@ class BonPrelevement extends CommonObject /* * End of procedure */ - if ($error == 0) + if (! $error) { $this->db->commit(); return 0; @@ -399,10 +404,10 @@ class BonPrelevement extends CommonObject } /** - * Set withdrawal to credited status + * Set direct debit order to "credited" status. * - * @param User $user id of user - * @param int $date date of action + * @param User $user Id of user + * @param int $date date of action * @return int >0 if OK, <0 if KO */ function set_infocredit($user, $date) @@ -436,49 +441,60 @@ class BonPrelevement extends CommonObject $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; $facs = array(); $amounts = array(); + $amountsperthirdparty = array(); $facs = $this->getListInvoices(1); + // Loop on each invoice. $facs=array(0=>id, 1=>amount requested) $num=count($facs); for ($i = 0; $i < $num; $i++) { $fac = new Facture($this->db); $fac->fetch($facs[$i][0]); $amounts[$fac->id] = $facs[$i][1]; + $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; $totalpaye = $fac->getSommePaiement(); $totalcreditnotes = $fac->getSumCreditNotesUsed(); $totaldeposits = $fac->getSumDepositsUsed(); $alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits; - if ($alreadypayed + $facs[$i][1] >= $fac->total_ttc) { + if (price2num($alreadypayed + $facs[$i][1], 'MT') == $fac->total_ttc) { $result = $fac->set_paid($user); } } - $paiement = new Paiement($this->db); - $paiement->datepaye = $date ; - $paiement->amounts = $amounts; - $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref ; - $paiement->id_prelevement = $this->id ; + // Make one payment per customer + foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) + { + $paiement = new Paiement($this->db); + $paiement->datepaye = $date; + $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice + $paiement->paiementid = 3; // + $paiement->num_paiement = $this->ref; // Set ref of direct debit note + $paiement->id_prelevement = $this->id; - $paiement_id = $paiement->create($user); - if ($paiement_id < 0) - { - dol_syslog(get_class($this)."::set_credite AddPayment Error"); - $error++; + $paiement_id = $paiement->create($user); + if ($paiement_id < 0) + { + dol_syslog(get_class($this)."::set_infocredit AddPayment Error"); + $error++; + } + else + { + $result=$paiement->addPaymentToBank($user,'payment','(WithdrawalPayment)',$bankaccount,'',''); + if ($result < 0) + { + dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error"); + $error++; + } + } + //var_dump($paiement->amounts); + //var_dump($thirdpartyid); + //var_dump($cursoramounts); } - else - { - $result=$paiement->addPaymentToBank($user,'payment','(WithdrawalPayment)',$bankaccount,'',''); - if ($result < 0) - { - dol_syslog(get_class($this)."::set_credite AddPaymentToBank Error"); - $error++; - } - } - // Update withdrawal line + + // Update withdrawal line // TODO: Translate to ligneprelevement.class.php $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql.= " SET statut = 2"; @@ -486,7 +502,7 @@ class BonPrelevement extends CommonObject if (! $this->db->query($sql)) { - dol_syslog(get_class($this)."::set_credite Update lines Error"); + dol_syslog(get_class($this)."::set_infocredit Update lines Error"); $error++; } @@ -951,14 +967,14 @@ class BonPrelevement extends CommonObject } } - /* - * Create withdrawal receipt - */ if (!$error) { - if (count($factures_prev) > 0) + /* + * Create withdrawal receipt in database + */ + if (count($factures_prev) > 0) { - foreach ($factures_prev as $fac) + foreach ($factures_prev as $fac) // Add a link in database for each invoice { // Fetch invoice $fact = new Facture($this->db); @@ -998,7 +1014,6 @@ class BonPrelevement extends CommonObject } } - } } @@ -1006,11 +1021,12 @@ class BonPrelevement extends CommonObject if (!$error) { /* - * Withdraw receipt + * Create direct debit order in a XML file */ dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG); + if (count($factures_prev) > 0) { $this->date_echeance = $datetimeprev; @@ -1034,11 +1050,12 @@ class BonPrelevement extends CommonObject $this->factures = $factures_prev_id; - // Generation of SEPA file + // Generation of SEPA file $this->filename $this->generate(); } dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } + //var_dump($factures_prev);exit; /* * Update total @@ -1289,8 +1306,9 @@ class BonPrelevement extends CommonObject $sql.= " AND soc.rowid = f.fk_soc"; $sql.= " AND rib.fk_soc = f.fk_soc"; $sql.= " AND rib.default_rib = 1"; + //print $sql; - //echo $sql; + // Define $fileDebiteurSection. One section DrctDbtTxInf per invoice. $resql=$this->db->query($sql); if ($resql) { @@ -1302,27 +1320,26 @@ class BonPrelevement extends CommonObject $this->total = $this->total + $obj->somme; $i++; } + $nbtotalDrctDbtTxInf = $i; } else { - fputs($this->file, 'ERREUR DEBITEUR '.$sql.$CrLf); + fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers $result = -2; } - /* - * section Emetteur(sepa Emetteur bloc lines) - */ + // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf if ($result != -2) { - $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $i, $this->total, $CrLf); + $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf); } else { - fputs($this->file, 'ERREUR EMETTEUR'.$CrLf); + fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company } /** - * SECTION CREATION FICHIER SEPA + * SECTION CREATION SEPA FILE */ // SEPA File Header fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf); @@ -1819,11 +1836,11 @@ class BonPrelevement extends CommonObject } /** - * Return status label for a status + * Return status label for a status * - * @param int $statut id statut - * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto - * @return string Label + * @param int $statut id statut + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label */ function LibStatut($statut,$mode=0) { @@ -1846,8 +1863,25 @@ class BonPrelevement extends CommonObject if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); } - if ($mode == 3) + { + if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); + if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + } + if ($mode == 4) + { + if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + } + if ($mode == 5) + { + if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); + if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + } + if ($mode == 6) { if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 0834b3500a7..6743ea3098b 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -67,7 +67,7 @@ if ($action == 'create') { setEventMessages($bprev->error, $bprev->errors, 'errors'); } - if ($result == 0) + elseif ($result == 0) { $mesg=''; $mesg=$langs->trans("NoInvoiceCouldBeWithdrawed"); @@ -78,6 +78,10 @@ if ($action == 'create') $mesg.=$val."
\n"; } } + else + { + setEventMessages($langs->trans("DirectDebitOrderCreated"), null); + } } diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 437af529ad9..f7e41bdc997 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -43,6 +43,7 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); $socid = GETPOST('socid','int'); +$ref = GETPOST('ref', 'alpha'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -55,6 +56,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='p.ref'; if (! $sortorder) $sortorder='DESC'; +$object = new BonPrelevement($db,""); + + /* * View @@ -65,39 +69,41 @@ $thirdpartytmp = new Societe($db); llxHeader('',$langs->trans("WithdrawalsReceipts")); -if ($prev_id) +if ($prev_id > 0 || $ref) { - $bon = new BonPrelevement($db,""); - - if ($bon->fetch($prev_id) == 0) + if ($object->fetch($prev_id, $ref) == 0) { - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); + + print '
'; + print '
'; print ''; - print ''; - print ''; - print ''; + //print ''; + print ''; + print ''; // Status - print ''; + //print ''; - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -105,12 +111,29 @@ if ($prev_id) print '
'; - print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).'
'.$langs->trans('Status').''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); } @@ -137,7 +160,6 @@ $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity = ".$conf->entity; if ($prev_id) $sql.= " AND p.rowid=".$prev_id; if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= $db->order($sortfield,$sortorder); // Count total nb of records @@ -172,9 +194,10 @@ if ($result) $massactionbutton=''; - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + print_barre_liste($langs->trans("Invoices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); print"\n\n"; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print_liste_field_titre("Bill",$_SERVER["PHP_SELF"],"p.ref",'',$param,'',$sortfield,$sortorder); @@ -243,13 +266,18 @@ if ($result) print ''; print ''; print ''; - print '\n"; + print '\n"; print ''; print ''; print "\n"; } print "
'.$langs->trans("Total").' '.price($total)."'; + if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + print price($total); + print "  
"; + print '
'; + $db->free($result); } else diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index f2240a070e6..b3b9898659d 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -41,49 +41,69 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +$object = new BonPrelevement($db,""); + + + /* * View */ + llxHeader('',$langs->trans("WithdrawalsReceipts")); -if ($prev_id) +if ($prev_id > 0 || $ref) { - $bon = new BonPrelevement($db,""); - - if ($bon->fetch($prev_id) == 0) + if ($object->fetch($prev_id, $ref) == 0) { - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); - print ''; + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); - print ''; - print ''; - print ''; + print '
'; + print '
'; + print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'."\n"; + + //print ''; + print ''; + print ''; // Status + /* print ''; - print ''; + print ''; print ''; + */ - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -91,12 +111,29 @@ if ($prev_id) print '
'; - print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); } @@ -109,7 +146,7 @@ if ($prev_id) $rej = new RejetPrelevement($db, $user); /* - * Liste des factures + * List errors */ $sql = "SELECT pl.rowid, pl.amount, pl.statut"; $sql.= " , s.rowid as socid, s.nom as name"; @@ -127,12 +164,25 @@ $sql.= " AND pr.fk_prelevement_lignes = pl.rowid"; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY pl.amount DESC"; +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit+1, $offset); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + print"\n\n"; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -146,32 +196,32 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print '\n"; - + print '\n"; print ''; - + print ''; print ''; print "\n"; - + $total += $obj->amount; - + $i++; } } else { - print ''; + print ''; } - + if ($num > 0) { print ''; @@ -181,6 +231,8 @@ if ($resql) print "\n"; } print "
'.$langs->trans("Line").''.$langs->trans("ThirdParty").''.$langs->trans("Amount").'
'; - + print ''; print img_picto('', 'statut'.$obj->statut).' '; print substr('000000'.$obj->rowid, -6); print ''.$obj->name."'.price($obj->amount)."'.$rej->motifs[$obj->motif].''.yn($obj->afacturer).''.$obj->fk_facture.'
'.$langs->trans("None").'
'.$langs->trans("None").'
 
\n"; + print '
'; + $db->free($resql); } else diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 7e0c4f81e4b..ac2c1e4da9b 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -38,7 +38,21 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + + +$object = new BonPrelevement($db,""); + /* * View @@ -48,40 +62,44 @@ llxHeader('',$langs->trans("WithdrawalsReceipts")); if ($prev_id) { - $bon = new BonPrelevement($db,""); - - if ($bon->fetch($prev_id) == 0) + if ($object->fetch($prev_id) == 0) { - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); - print ''; + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); - print ''; - print ''; - print ''; + print '
'; + print '
'; + print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'."\n"; + + //print ''; + print ''; + print ''; // Status + /* print ''; - print ''; + print ''; print ''; + */ - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -89,12 +107,29 @@ if ($prev_id) print '
'; - print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); } @@ -121,7 +156,7 @@ if ($prev_id) $i = 0; print load_fiche_titre($langs->trans("StatisticsByLineStatus"),'',''); - + print"\n\n"; print ''; print ''; @@ -139,12 +174,12 @@ if ($prev_id) print price($row[0]); print ''; print "\n"; - + $i++; } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 7dffd99f8bf..2d6f728b502 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -224,7 +224,7 @@ if (empty($reshook)) $action = 'create'; } else { // Categories association - $contcats = GETPOST( 'contcats', 'array' ); + $contcats = GETPOST( 'contcats', 'array'); $object->setCategories($contcats); } } @@ -383,7 +383,7 @@ if (empty($reshook)) $db->query( $sql ); // Then we add the associated categories - $categories = GETPOST( 'contcats', 'array' ); + $categories = GETPOST( 'contcats', 'array'); $object->setCategories($categories); $object->old_lastname=''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5b109c7b0d7..16c843466f9 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -965,6 +965,7 @@ if (empty($reshook)) $trackid='cont'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { if ($action == 'addcontact') @@ -2052,62 +2053,73 @@ else $parameters=array(); $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if ($object->statut == 0 && $nbofservices) + if (empty($reshook)) { - if ($user->rights->contrat->creer) print ''; - else print ''; - } - if ($object->statut == 1) - { - if ($user->rights->contrat->creer) print ''; - else print ''; - } + // Send + if ($object->statut == 1) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { + print ''; + } else + print ''; + } - if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) - { - $langs->load("bills"); - if ($user->rights->facture->creer) print ''; - else print ''; - } + if ($object->statut == 0 && $nbofservices) + { + if ($user->rights->contrat->creer) print ''; + else print ''; + } + if ($object->statut == 1) + { + if ($user->rights->contrat->creer) print ''; + else print ''; + } - if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) - { - $langs->load("orders"); - if ($user->rights->commande->creer) print ''; - else print ''; - } + if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) + { + $langs->load("bills"); + if ($user->rights->facture->creer) print ''; + else print ''; + } - // Clone - if ($user->rights->contrat->creer) { - print ''; - } + if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) + { + $langs->load("orders"); + if ($user->rights->commande->creer) print ''; + else print ''; + } - if ($object->nbofservicesclosed > 0) - { - print ''; - } - if ($object->nbofservicesclosed < $nbofservices) - { - //if (! $numactive) - //{ - print ''; - //} - //else - //{ - // print ''; - //} - } + // Clone + if ($user->rights->contrat->creer) { + print ''; + } - // On peut supprimer entite si - // - Droit de creer + mode brouillon (erreur creation) - // - Droit de supprimer - if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) - { - print ''; - } - else - { - print ''; + if ($object->nbofservicesclosed > 0) + { + print ''; + } + if ($object->nbofservicesclosed < $nbofservices) + { + //if (! $numactive) + //{ + print ''; + //} + //else + //{ + // print ''; + //} + } + + // On peut supprimer entite si + // - Droit de creer + mode brouillon (erreur creation) + // - Droit de supprimer + if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) + { + print ''; + } + else + { + print ''; + } } print ""; @@ -2193,7 +2205,7 @@ else print '
'; print '
'; print '
'; - print load_fiche_titre($langs->trans('SendContractByMail')); + print load_fiche_titre($langs->trans('SendByMail')); dol_fiche_head(''); @@ -2207,7 +2219,7 @@ else $formmail->fromid = $user->id; } - $formmail->trackid='ord'.$object->id; + $formmail->trackid='cont'.$object->id; if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -2229,9 +2241,18 @@ else $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; - // Tableau des substitutions + // Array of substitutions $formmail->setSubstitFromObject($object); - $formmail->substit ['__CONTRACTREF__'] = $object->ref; + $datenextexpiration=''; + foreach($object->lines as $line) + { + if ($line->statut != 4) continue; + if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue; + } + $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); + $formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); + $formmail->substit['__PERSONALIZED__']=''; + $formmail->substit['__CONTACTCIVNAME__']=''; $custcontact = ''; $contactarr = array(); @@ -2243,7 +2264,7 @@ else { if ($contact['libelle'] == $langs->trans('TypeContact_contract_external_CUSTOMER')) { // TODO Use code and not label $contactstatic = new Contact($db); - $contactstatic->fetch($contact ['id']); + $contactstatic->fetch($contact['id']); $custcontact = $contactstatic->getFullName($langs, 1); } } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index beba40103af..cfc4d07ab1d 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -29,8 +29,9 @@ */ require ("../main.inc.php"); -require_once (DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); +require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -52,6 +53,7 @@ $search_state=trim(GETPOST("search_state")); $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_contract=GETPOST('search_contract'); +$search_ref_customer=GETPOST('search_ref_customer','alpha'); $search_ref_supplier=GETPOST('search_ref_supplier','alpha'); $sall=GETPOST('sall', 'alphanohtml'); $search_status=GETPOST('search_status'); @@ -81,6 +83,8 @@ $id=GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contrat', $id); +$diroutputmassaction=$conf->contrat->dir_output . '/temp/massgeneration/'.$user->id; + $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); @@ -158,6 +162,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_type=''; $search_country=''; $search_contract=""; + $search_ref_customer=""; $search_ref_supplier=""; $search_user=''; $search_sale=''; @@ -184,7 +189,8 @@ if (empty($reshook)) */ $now=dol_now(); -$form=new Form($db); +$form = new Form($db); +$formfile = new FormFile($db); $formother = new FormOther($db); $socstatic = new Societe($db); $contracttmp = new Contrat($db); @@ -241,6 +247,7 @@ else if ($year > 0) } if ($search_name) $sql .= natural_search('s.nom', $search_name); if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); +if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer'), $search_ref_customer); if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); if ($search_sale > 0) { @@ -334,8 +341,8 @@ if ($resql) // List of mass actions available $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), + 'presend'=>$langs->trans("SendByMail"), + 'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->contrat->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); @@ -352,6 +359,16 @@ if ($resql) print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit); + if ($massaction == 'presend') + { + $topicmail="SendContractRef"; + $modelmail="contract"; + $objecttmp=new Contrat($db); + $trackid='con'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; + } + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -417,13 +434,13 @@ if ($resql) if (! empty($arrayfields['c.ref_customer']['checked'])) { print ''; } if (! empty($arrayfields['c.ref_supplier']['checked'])) { print ''; } if (! empty($arrayfields['s.nom']['checked'])) @@ -586,6 +603,13 @@ if ($resql) print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; print ''; } + + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->contrat->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); + print ''; + print ''; } if (! empty($arrayfields['c.ref_customer']['checked'])) @@ -750,6 +774,25 @@ if ($resql) print ''; print ''; + + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + /* + * Show list of available documents + */ + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->contrat->lire; + $delallowed=$user->rights->contrat->lire; + + print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } } else { diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index e5a5c21c00b..9d1db86ded6 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -285,7 +285,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader(null, $langs->trans("Services")); $param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_contract) $param.='&search_contract='.urlencode($search_contract); if ($search_name) $param.='&search_name='.urlencode($search_name); @@ -326,6 +326,7 @@ print ''; print ''; print ''; print ''; +print ''; $title=$langs->trans("ListOfServices"); if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0" diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index 7c25fbe7981..6a2d7196d0f 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -28,7 +28,7 @@ // $cancel must be defined // $id or $ref must be defined (object is loaded in this file with fetch) -if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && empty($cancel)) +if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) { $ret = $object->fetch($id, $ref); if ($ret > 0) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 6750aa5de38..b17c047860a 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -52,7 +52,7 @@ if (! $error && count($toselect) > $maxformassaction) $error++; } -if (! $error && $massaction == 'confirm_presend' && GETPOST('modelselected')) // If we change the template, we must not send email, but keep on send email form +if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form { $massaction='presend'; } @@ -64,35 +64,63 @@ if (! $error && $massaction == 'confirm_presend') $langs->load("mails"); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (!$error && !isset($user->email)) - { - $error++; - setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); - } + $listofobjectid=array(); + $listofobjectthirdparties=array(); + $listofobjectref=array(); if (! $error) { $thirdparty=new Societe($db); + if ($objecttmp->element == 'expensereport') $thirdparty=new User($db); + $objecttmp=new $objectclass($db); - $listofobjectid=array(); - $listofobjectthirdparties=array(); - $listofobjectref=array(); foreach($toselect as $toselectid) { - $objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use + $objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use $result=$objecttmp->fetch($toselectid); if ($result > 0) { $listofobjectid[$toselectid]=$toselectid; $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; + if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id; + if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author; $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; } } - //var_dump($listofobjectthirdparties);exit; + } + // Check mandatory parameters + if (empty($user->email)) + { + $error++; + setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); + $massaction='presend'; + } - // Loop on each thirdparty + $receiver=$_POST['receiver']; + if (! is_array($receiver)) + { + if (empty($receiver) || $receiver == '-1') $receiver=array(); + else $receiver=array($receiver); + } + if (count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); + $massaction='presend'; + } + + if (! GETPOST('subject','none')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings'); + $massaction='presend'; + } + + // Loop on each recipient/thirdparty + if (! $error) + { foreach ($listofobjectthirdparties as $thirdpartyid) { $result = $thirdparty->fetch($thirdpartyid); @@ -108,12 +136,6 @@ if (! $error && $massaction == 'confirm_presend') $sendtoid = array(); // Define $sendto - $receiver=$_POST['receiver']; - if (! is_array($receiver)) - { - if ($receiver == '-1') $receiver=array(); - else $receiver=array($receiver); - } $tmparray=array(); if (trim($_POST['sendto'])) { @@ -172,74 +194,99 @@ if (! $error && $massaction == 'confirm_presend') $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); $listofqualifiedid=array(); $listofqualifiedref=array(); + $thirdpartywithoutemail=array(); + foreach($listofobjectref[$thirdpartyid] as $objectid => $object) { //var_dump($thirdpartyid.' - '.$objectid.' - '.$object->statut); - - if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED) + if ($objectclass == 'Propal' && $object->statut == Propal::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$object->ref).'

'; + $resaction.='
'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$object->ref).'

'; continue; // Payment done or started or canceled } - if ($objectclass == 'Commande' && $object->statut == Commande::STATUS_DRAFT) + if ($objectclass == 'Commande' && $object->statut == Commande::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; $resaction.='
'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction',$object->ref).'

'; continue; } - - // Read document - // TODO Use future field $object->fullpathdoc to know where is stored default file - // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. - $filename=dol_sanitizeFileName($object->ref).'.pdf'; - $filedir=$uploaddir . '/' . dol_sanitizeFileName($object->ref); - $file = $filedir . '/' . $filename; - $mime = dol_mimetype($file); - - if (dol_is_file($file)) + if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED) { - if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) - { - $object->fetch_thirdparty(); - $sendto = $object->thirdparty->email; - } - - if (empty($sendto)) - { - //print "No recipient for thirdparty ".$object->thirdparty->name; - $nbignored++; - continue; - } - - if (dol_strlen($sendto)) - { - // Create form object - $attachedfiles=array( - 'paths'=>array_merge($attachedfiles['paths'],array($file)), - 'names'=>array_merge($attachedfiles['names'],array($filename)), - 'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) - ); - } - - $listofqualifiedid[$objectid]=$object; - $listofqualifiedref[$objectid]=$object->ref; - } - else - { - $nbignored++; - $langs->load("errors"); - $resaction.='
'.$langs->trans('ErrorCantReadFile',$file).'

'; - dol_syslog('Failed to read file: '.$file, LOG_WARNING); - continue; + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$object->ref).'

'; + continue; // Payment done or started or canceled } + // Test recipient + if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) + { + if ($object->element == 'expensereport') + { + $fuser = new User($db); + $fuser->fetch($object->fk_user_author); + $sendto = $fuser->email; + } + else + { + $object->fetch_thirdparty(); + $sendto = $object->thirdparty->email; + } + } + + if (empty($sendto)) + { + //print "No recipient for thirdparty ".$object->thirdparty->name; + $nbignored++; + if (empty($thirdpartywithoutemail[$object->thirdparty->id])) + { + $resaction.='
'.$langs->trans('NoRecipientEmail',$object->thirdparty->name).'

'; + } + dol_syslog('No recipient for thirdparty: '.$object->thirdparty->name, LOG_WARNING); + $thirdpartywithoutemail[$object->thirdparty->id]=1; + continue; + } + + if ($_POST['addmaindocfile']) + { + // TODO Use future field $object->fullpathdoc to know where is stored default file + // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. + $filename=dol_sanitizeFileName($object->ref).'.pdf'; + $filedir=$uploaddir . '/' . dol_sanitizeFileName($object->ref); + $file = $filedir . '/' . $filename; + $mime = dol_mimetype($file); + + if (dol_is_file($file)) + { + // Create form object + $attachedfiles=array( + 'paths'=>array_merge($attachedfiles['paths'],array($file)), + 'names'=>array_merge($attachedfiles['names'],array($filename)), + 'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) + ); + } + else + { + $nbignored++; + $langs->load("errors"); + $resaction.='
'.$langs->trans('ErrorCantReadFile',$file).'

'; + dol_syslog('Failed to read file: '.$file, LOG_WARNING); + continue; + } + } + + // Object of thirdparty qualified + $listofqualifiedid[$objectid]=$object; + $listofqualifiedref[$objectid]=$object->ref; + + //var_dump($listofqualifiedref); } - // Loop on each qualified objects of the thirdparty + // Send email if there is at least one qualified record if (count($listofqualifiedid) > 0) { $langs->load("commercial"); @@ -264,8 +311,8 @@ if (! $error && $massaction == 'confirm_presend') } $replyto = $from; - $subject = GETPOST('subject'); - $message = GETPOST('message'); + $subject = GETPOST('subject','none'); + $message = GETPOST('message','none'); $sendtocc = GETPOST('sentocc'); $sendtobcc = ''; if ($objectclass == 'Propale') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO); @@ -275,28 +322,18 @@ if (! $error && $massaction == 'confirm_presend') if ($objectclass == 'CommandeFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO); if ($objectclass == 'FactureFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO); + $objecttmp=new $objectclass($db); + $objecttmp->thirdparty = $thirdparty; - $substitutionarray=array( - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__ID__' => join(', ',array_keys($listofqualifiedid)), - '__EMAIL__' => $thirdparty->email, - '__CHECK_READ__' => '', - '__FACREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__ORDERREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__PROPREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__REF__' => join(', ',$listofqualifiedref), - '__REFCLIENT__' => $thirdparty->name, - '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'') - /* not available on all object - /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''), - '__LASTNAME__'=>(is_object($object)?$object->lastname:''), - '__FULLNAME__'=>(is_object($object)?$object->getFullName($langs):''), - '__ADDRESS__'=>(is_object($object)?$object->address:''), - '__ZIP__'=>(is_object($object)?$object->zip:''), - '__TOWN_'=>(is_object($object)?$object->town:''), - '__COUNTRY__'=>(is_object($object)?$object->country:''), - */ - ); + // Make substitution in email content + $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); + $substitutionarray['__ID__'] = join(', ',array_keys($listofqualifiedid)); + $substitutionarray['__EMAIL__'] = $thirdparty->email; + $substitutionarray['__CHECK_READ__'] = ''; + $substitutionarray['__REF__'] = join(', ',$listofqualifiedref); + + $parameters=array('mode'=>'formemail'); + complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); $subject=make_substitutions($subject, $substitutionarray); $message=make_substitutions($message, $substitutionarray); @@ -350,18 +387,32 @@ if (! $error && $massaction == 'confirm_presend') $object->fk_element = $objid; $object->elementtype = $object->element; - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers + $triggername = strtoupper(get_class($object)) .'_SENTBYMAIL'; + if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL'; + if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYEMAIL'; + if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYEMAIL'; + if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYEMAIL'; + if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYEMAIL'; + if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL'; + if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL'; + if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL'; - if ($error) + if (! empty($trigger_name)) { - setEventMessages($db->lasterror(), $errors, 'errors'); - dol_syslog("Error in trigger BILL_SENTBYMAIL ".$db->lasterror(), LOG_ERR); + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers($trigger_name, $object, $user, $langs, $conf); + if ($result < 0) { $error++; $errors=$interface->errors; } + // Fin appel triggers + + if ($error) + { + setEventMessages($db->lasterror(), $errors, 'errors'); + dol_syslog("Error in trigger ".$trigger_name.' '.$db->lasterror(), LOG_ERR); + } } + $nbsent++; } } @@ -400,14 +451,20 @@ if (! $error && $massaction == 'confirm_presend') //setEventMessages($langs->trans("EMailSentToNRecipients", 0), null, 'warnings'); // May be object has no generated PDF file setEventMessages($resaction, null, 'warnings'); } - } - $action='list'; - $massaction=''; + $action='list'; + $massaction=''; + } } if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) { + if (empty($diroutputmassaction)) + { + dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined'); + exit; + } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -458,15 +515,15 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se $outputlangs->setDefaultLang($newlang); } - if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) + if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) { // Create output dir if not exists dol_mkdir($diroutputmassaction); - + // Defined name of merged file $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); $filename=preg_replace('/\s/','_',$filename); - + // Save merged file if ($filter=='paye:0') { @@ -502,7 +559,13 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se } else { // Create empty PDF - $pdf=pdf_getInstance(); + $formatarray=pdf_getFormat(); + $page_largeur = $formatarray['width']; + $page_hauteur = $formatarray['height']; + $format = array($page_largeur,$page_hauteur); + + $pdf=pdf_getInstance($format); + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -573,7 +636,7 @@ if ($action == 'remove_file') $action=''; } -// Validate records +// Validate records if (! $error && $massaction == 'validate' && $permtocreate) { if ($object->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) @@ -645,8 +708,19 @@ if (! $error && $massaction == 'delete' && $permtodelete) $result=$objecttmp->fetch($toselectid); if ($result > 0) { + // Refuse deletion for some status ? + /* + if ($objectclass == 'Facture' && $objecttmp->status == Facture::STATUS_DRAFT) + { + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$object->ref).'

'; + continue; + }*/ + if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index a16e0437952..144cba07779 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -24,7 +24,7 @@ // $mysoc must be defined // $id must be defined // $paramname must be defined -// $mode must be defined +// $mode must be defined (used to know the automatic BCC to add) // $trigger_name must be set (can be '') // $actiontypecode can be set // $object and $uobject may be defined @@ -258,7 +258,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; + $message = GETPOST('message','none'); + $subject = GETPOST('subject','none'); // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. // @@ -267,18 +268,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $message=preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); $sendtobcc= GETPOST('sendtoccc'); - if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); - if ($mode == 'emailfromsupplierproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); - if ($mode == 'emailfromsupplierorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); - if ($mode == 'emailfromsupplierinvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); + // Autocomplete the $sendtobcc + // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO... + if (! empty($autocopy)) + { + $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy)); + } $deliveryreceipt = $_POST['deliveryreceipt']; if ($action == 'send' || $action == 'relance') { - if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1); if ($message) { @@ -344,23 +344,25 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } - $substitutionarray=array( - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__ID__' => (is_object($object)?$object->id:''), - '__EMAIL__' => $sendto, - '__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'':'', - '__REF__' => (is_object($object)?$object->ref:''), - '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'') - /* not available on all object - /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''), - '__LASTNAME__'=>(is_object($object)?$object->lastname:''), - '__FULLNAME__'=>(is_object($object)?$object->getFullName($langs):''), - '__ADDRESS__'=>(is_object($object)?$object->address:''), - '__ZIP__'=>(is_object($object)?$object->zip:''), - '__TOWN_'=>(is_object($object)?$object->town:''), - '__COUNTRY__'=>(is_object($object)?$object->country:''), - */ - ); + // Make substitution in email content + $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); + $substitutionarray['__EMAIL__'] = $sendto; + $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'':''; + // Add specific substitution for contracts + if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) + { + $datenextexpiration=''; + foreach($object->lines as $line) + { + if ($line->statut != 4) continue; + if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue; + } + $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); + $substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); + } + + $parameters=array('mode'=>'formemail'); + complete_substitutions_array($substitutionarray, $langs, $object, $parameters); $subject=make_substitutions($subject, $substitutionarray); $message=make_substitutions($message, $substitutionarray); @@ -424,7 +426,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); - if ($result < 0) { + if ($result < 0) { $error++; $errors=$interface->errors; } } diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 02b1d1880c8..71a9a4e3125 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -77,7 +77,6 @@ class box_activity extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $totalMnt = 0; $totalnb = 0; $line = 0; $cachetime = 3600; @@ -95,8 +94,6 @@ class box_activity extends ModeleBoxes // compute the year limit to show $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m"); - $cumuldata = array(); - // list the summary of the propals if (! empty($conf->propal->enabled) && $user->rights->propale->lire) @@ -146,11 +143,10 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -176,7 +172,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), @@ -231,10 +226,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, @@ -259,7 +253,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3), @@ -290,11 +283,11 @@ class box_activity extends ModeleBoxes $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -317,10 +310,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($j < count($data)) { $billurl="search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -347,10 +339,8 @@ class box_activity extends ModeleBoxes ); // We add only for the current year - if ($data[$j]->annee == date("Y")) { - $totalnb += $data[$j]->nb; - $totalMnt += $data[$j]->Mnttot; - } + $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), @@ -371,12 +361,13 @@ class box_activity extends ModeleBoxes $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND paye=0"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -399,11 +390,11 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { - $j=0; + $alreadypaid=-1; - while ($line < count($cumuldata)) { + $j=0; + while ($j < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -428,10 +419,9 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $objp->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), + 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid), ); $line++; $j++; @@ -441,11 +431,6 @@ class box_activity extends ModeleBoxes 'td' => 'align="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), - ); } } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2be205fa5c9..a9802db1205 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -309,7 +309,7 @@ abstract class CommonInvoice extends CommonObject * @param int $paye Status field paye * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) * @param int $type Type invoice * @return string Libelle du statut */ diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 5a88956e5bc..abdbb1689f8 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -48,7 +48,7 @@ class Events // extends CommonObject var $dateevent; var $description; - // List of all events supported by triggers + // List of all Audit/Security events supported by triggers var $eventstolog=array( array('id'=>'USER_LOGIN', 'test'=>1), array('id'=>'USER_LOGIN_FAILED', 'test'=>1), diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6089c9a11ff..c054bde0880 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -956,7 +956,7 @@ class Form */ function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0) { - return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit); + return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0, $limit); } /** @@ -1082,7 +1082,7 @@ class Form $sql.=")"; } $sql.=$this->db->order("nom","ASC"); - if ($limit > 0) $sql.=$this->db->plimit($limit); + $sql.=$this->db->plimit($limit, 0); // Build output string dol_syslog(get_class($this)."::select_thirdparty_list", LOG_DEBUG); @@ -1966,7 +1966,7 @@ class Form $sql.= ' GROUP BY'.$selectFields; } $sql.= $db->order("p.ref"); - $sql.= $db->plimit($limit); + $sql.= $db->plimit($limit, 0); // Build output string dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG); @@ -2390,7 +2390,7 @@ class Form $sql.=')'; } $sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; - $sql.= $db->plimit($limit); + $sql.= $db->plimit($limit, 0); // Build output string @@ -3394,7 +3394,7 @@ class Form require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; $bankstatic=new Account($this->db); $bankstatic->fetch($selected); - print $this->textwithpicto($bankstatic->getNomUrl(1),$langs->trans("AccountCurrency").' '.$bankstatic->currency_code); + print $bankstatic->getNomUrl(1); } else { print " "; } @@ -5554,6 +5554,8 @@ class Form print '
'; print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, ''); + + print '
'; print '
'; - if ($bon->amount) print round($row[0]/$bon->amount*100,2)." %"; + if ($object->amount) print round($row[0]/$object->amount*100,2)." %"; print '
'; - print ''; + print ''; print ''; - print ''; + print ''; print '
'; print ''; @@ -5647,6 +5649,7 @@ class Form } print '
'; + print ''; return $nbofdifferenttypes; } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 15a9b781290..f09dab9be38 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -166,7 +166,10 @@ class FormActions require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', '', '', ($max?($max+1):0)); + $sortfield='a.datep'; + $sortorder='DESC'; + + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); $num = count($listofactions); @@ -192,19 +195,19 @@ class FormActions $buttontoaddnewevent.= ''; print load_fiche_titre($title, $buttontoaddnewevent, ''); - $page=0; $param=''; $sortfield='a.datep'; + $page=0; $param=''; $total = 0; print '
'; print ''; print ''; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Action', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, 'align="center"'); - print_liste_field_titre('By', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Action', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); print ''; print "\n"; @@ -247,12 +250,10 @@ class FormActions } print ''; print ''; print '
'; - if (! empty($action->author->id)) + if (! empty($action->userownerid)) { - $userstatic->id = $action->author->id; - $userstatic->firstname = $action->author->firstname; - $userstatic->lastname = $action->author->lastname; - print $userstatic->getNomUrl(1, '', 0, 0, 16, 0, '', ''); + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched + print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); } print ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 932cc211d12..366247560ac 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -63,6 +63,7 @@ class FormMail extends Form var $withtoccc; var $withtopic; var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files + var $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) var $withbody; var $withfromreadonly; @@ -103,7 +104,8 @@ class FormMail extends Form $this->withtoccc=0; $this->witherrorsto=0; $this->withtopic=1; - $this->withfile=0; + $this->withfile=0; // 1=Add section "Attached files". 2=Can add files. + $this->withmaindocfile=0; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) $this->withbody=1; $this->withfromreadonly=1; @@ -220,6 +222,7 @@ class FormMail extends Form /** * Show the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files + * this->withmaindocfile * * @param string $addfileaction Name of action when posting file attachments * @param string $removefileaction Name of action when removing file attachments @@ -233,6 +236,7 @@ class FormMail extends Form /** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files + * this->withfile * this->param: Contains more parameteres like email templates info * * @param string $addfileaction Name of action when posting file attachments @@ -296,16 +300,25 @@ class FormMail extends Form } $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); //var_dump($this->param["models"]); + //var_dump($model_id); //var_dump($arraydefaultmessage); - $out.= "\n".'
'."\n"; + $out.= "\n".'
'."\n"; if ($this->withform == 1) { $out.= '
'."\n"; - $out.= ''; + $out.= ''; + $out.= ''; $out.= ''; $out.= ''; - $out.= ''; + } + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + } } foreach ($this->param as $key=>$value) { @@ -330,7 +343,7 @@ class FormMail extends Form if (count($modelmail_array)>0) { $out.= '
'."\n"; - $out.= $langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1); + $out.= ''.$langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); $out.= '   '; $out.= ''; @@ -340,7 +353,7 @@ class FormMail extends Form elseif (! empty($this->param['models']) && in_array($this->param['models'], array( 'propal_send','order_send','facture_send', 'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send', - 'invoice_supplier_send','thirdparty','all' + 'invoice_supplier_send','thirdparty','contract','all' ))) { $out.= '
'."\n"; @@ -357,16 +370,19 @@ class FormMail extends Form $out.= ''."\n"; // Substitution array - if (! empty($this->withsubstit)) + if (! empty($this->withsubstit)) // Unset of set ->withsubstit=0 to disable this. { - $out.= '\n"; + //$out.=''; } // From @@ -374,9 +390,7 @@ class FormMail extends Form { if (! empty($this->withfromreadonly)) { - $out.= ''; - $out.= ''; - $out.= '\n"; - $out.= "\n"; } else { @@ -499,7 +513,7 @@ class FormMail extends Form { $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtoselected=GETPOST("receiver"); // Array of selected value + $withtoselected=GETPOST("receiver",'none'); // Array of selected value if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') { $withtoselected = array_keys($tmparray); @@ -632,9 +646,12 @@ class FormMail extends Form // Topic if (! empty($this->withtopic)) { - $defaulttopic=""; - if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) $defaulttopic=$arraydefaultmessage['topic']; - elseif (! is_numeric($this->withtopic)) $defaulttopic=$this->withtopic; + $defaulttopic=GETPOST('subject','none'); + if (! GETPOST('modelselected','alpha') || GETPOST('modelmailselected') != '-1') + { + if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) $defaulttopic=$arraydefaultmessage['topic']; + elseif (! is_numeric($this->withtopic)) $defaulttopic=$this->withtopic; + } $defaulttopic=make_substitutions($defaulttopic,$this->substit); @@ -660,9 +677,22 @@ class FormMail extends Form $out.= ''; $out.= ''; print "\n"; print '"; + print dol_print_date($db->jdate($objp->date_commande), 'dayhour').""; print '\n"; print '\n"; print ''; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index daf2a9c3654..4b9aa67236e 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -236,7 +236,7 @@ if ($id > 0 || ! empty($ref)) { print ''; print "\n"; print '"; + print dol_print_date($db->jdate($objp->date_commande), 'dayhour') . ""; print '\n"; print '\n"; print ''; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index f9eed565903..8780a8a6a3b 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -190,7 +190,7 @@ if ($id > 0 || ! empty($ref)) print ''; print "\n"; print ""; + print dol_print_date($db->jdate($objp->date_contrat), 'dayhour').""; //print "\n"; //print ''; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 8cdc0efd5c0..36359d1bd35 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -251,7 +251,7 @@ if ($id > 0 || ! empty($ref)) print ''; print "\n"; print '"; + print dol_print_date($db->jdate($objp->datef),'dayhour').""; print '\n"; print '\n"; print ''; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 586741496c2..6618d8deac8 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -229,7 +229,7 @@ if ($id > 0 || ! empty($ref)) print ''; print "\n"; print '"; + print dol_print_date($db->jdate($objp->datef), 'dayhour') . ""; print '\n"; print '\n"; print ''; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index a5801c422e0..3f6eae0bfce 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -230,7 +230,7 @@ if ($id > 0 || ! empty($ref)) $societestatic->fetch($objp->socid); print ''; print '"; + print dol_print_date($db->jdate($objp->datep), 'dayhour') . ""; print "\n"; print '' . "\n"; print ''; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php new file mode 100644 index 00000000000..1e0cefc3150 --- /dev/null +++ b/htdocs/product/stats/supplier_proposal.php @@ -0,0 +1,266 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * + * 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 . + */ + +/** + * \file htdocs/product/stats/supplier_proposal.php + * \ingroup product service propal + * \brief Page des stats des propals pour un produit + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; + +$langs->load("products"); +$langs->load("companies"); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + +// Security check +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); +$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +$socid=''; +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array ('productstatspropal')); + +$mesg = ''; + +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if ($page == - 1) { $page = 0;} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder = "DESC"; +if (! $sortfield) $sortfield = "p.date_valid"; + +$search_month = GETPOST('search_month', 'aplha'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) { + $search_month = ''; + $search_year = ''; +} + +/* + * View + */ + +$propalstatic = new SupplierProposal($db); +$societestatic=new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || ! empty($ref)) +{ + $product = new Product($db); + $result = $product->fetch($id, $ref); + + $object = $product; + + $parameters = array ('id' => $id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + llxHeader("", "", $langs->trans("CardProduct" . $product->type)); + + if ($result > 0) + { + $head = product_prepare_head($product); + $titre = $langs->trans("CardProduct" . $product->type); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); + dol_fiche_head($head, 'referers', $titre, -1, $picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + $out.= '
'; + //$out.='
'; $help=""; foreach($this->substit as $key => $val) { - $help.=$key.' -> '.$langs->trans($val).'
'; + $help.=$key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'
'; } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help); + if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage + else $out.= $form->textwithpicto($langs->trans('AvailableVariables'), $help, 1, 'help', '', 0, 2, 'substittooltip'); // New usage $out.= "
'.$langs->trans("MailFrom").''; + $out.= '
'.$langs->trans("MailFrom").''; if (! ($this->fromtype === 'user' && $this->fromid > 0) && ! ($this->fromtype === 'company') @@ -429,10 +443,10 @@ class FormMail extends Form } } $out.= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails); + //$out.= ajax_combobox('fromtype'); } $out.= "
'.$langs->trans("MailFile").''; + if (! empty($this->withmaindocfile)) + { + if ($this->withmaindocfile == 1) + { + $out.=''; + } + if ($this->withmaindocfile == -1) + { + $out.=''; + } + $out.=' '.$langs->trans("JoinMainDoc").'.
'; + } + if (is_numeric($this->withfile)) { - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out.= ''."\n"; $out.= ' @@ -76,37 +76,37 @@ - + - +
- +
Cet inventaire est validé
- + - + $row) { - + + foreach ($lines as $k=>$row) { + $total_pmp+=$row['pmp_stock']; $total_pa+=$row['pa_stock']; $total_pmp_actual+=$row['pmp_actual']; $total_pa_actual+=$row['pa_actual']; - + if($i%20 === 0) { _headerList($view); @@ -126,18 +126,18 @@ if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ echo ''; $total_current_pa+=$row['current_pa_stock']; - } - + } + ?> rights->stock->changePMP)) { - echo ''; + echo ''; } ?> @@ -145,8 +145,8 @@ if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ echo ''; $total_current_pa_actual+=$row['current_pa_actual']; - } - + } + ?> @@ -154,25 +154,25 @@ -
'.price($row['current_pa_stock']).'    - + '.$row['pmp_new'].''.$row['pmp_new'].''.price($row['current_pa_actual']).'
- + status != 1) { ?>
trans('Modify') ?> - rights->stock->changePMP)) { echo ''.$langs->trans('ApplyPMP').''; } - + if ($can_validate == 1) { ?> trans('RegulateStock') ?> @@ -193,13 +193,13 @@ trans('Delete') ?> - +

Date de création : getDate('datec') ?> -
Dernière mise à jour : getDate('tms') ?>

- +
Dernière mise à jour : getDate('tms') ?>

+ + - diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 5a371554058..4eb8992d837 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -228,7 +228,7 @@ if ($id > 0 || ! empty($ref)) print '
'.$societestatic->getNomUrl(1).'".$objp->code_client."'; - print dol_print_date($db->jdate($objp->date_commande))."'.$objp->qty."'.price($objp->total_ht)."'.$orderstatic->LibStatut($objp->statut,$objp->facture,5).'' . $societestatic->getNomUrl(1) . '" . $objp->code_client . "'; - print dol_print_date($db->jdate($objp->date_commande)) . "' . $objp->qty . "' . price($objp->total_ht) . "' . $supplierorderstatic->getLibStatut(4) . ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->name,44).'".$objp->code_client.""; - print dol_print_date($db->jdate($objp->date_contrat))."".price($objp->total_ht)."'; print ''.($objp->nb_initial>0?$objp->nb_initial:'').''.$societestatic->getNomUrl(1).'".$objp->code_client."'; - print dol_print_date($db->jdate($objp->datef),'day')."'.$objp->qty."'.price($objp->total_ht)."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'' . $societestatic->getNomUrl(1) . '" . $objp->code_client . "'; - print dol_print_date($db->jdate($objp->datef)) . "' . $objp->qty . "' . price($objp->total_ht) . "' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ''.$societestatic->getNomUrl(1).''; - print dol_print_date($db->jdate($objp->datep)) . "" . $objp->qty . "' . price($objp->amount) . '' . $propalstatic->LibStatut($objp->statut, 5) . '
'; + + show_stats_for_company($product, $socid); + + print "
"; + + print '
'; + print '
'; + + dol_fiche_end(); + + + if ($user->rights->propale->lire) + { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; + //$sql .= " p.ref_supplier,"; + $sql .= "p.date_valid, p.fk_statut as statut, d.rowid, d.qty"; + if (! $user->rights->societe->client->voir && ! $socid) + $sql .= ", sc.fk_soc, sc.fk_user "; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; + $sql .= "," . MAIN_DB_PREFIX . "supplier_proposal as p"; + $sql .= ", " . MAIN_DB_PREFIX . "supplier_proposaldet as d"; + if (! $user->rights->societe->client->voir && ! $socid) + $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND d.fk_supplier_proposal = p.rowid"; + $sql .= " AND d.fk_product =" . $product->id; + if (! empty($search_month)) + $sql .= ' AND MONTH(p.datep) IN (' . $search_month . ')'; + if (! empty($search_year)) + $sql .= ' AND YEAR(p.datep) IN (' . $search_year . ')'; + if (! $user->rights->societe->client->voir && ! $socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; + if ($socid) + $sql .= " AND p.fk_soc = " . $socid; + $sql .= " ORDER BY $sortfield $sortorder "; + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + $totalrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + if ($result) { + $totalrecords = $db->num_rows($result); + while ( $objp = $db->fetch_object($result) ) { + $total_ht += $objp->amount; + $total_qty += $objp->qty; + } + } + } + + $sql .= $db->plimit($conf->liste_limit + 1, $offset); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + + if (! empty($id)) + $option .= '&id=' . $product->id; + if (! empty($search_month)) + $option .= '&search_month=' . $search_month; + if (! empty($search_year)) + $option .= '&search_year=' . $search_year; + + print '
' . "\n"; + if (! empty($sortfield)) + print ''; + if (! empty($sortorder)) + print ''; + if (! empty($page)) { + print ''; + $option .= '&page=' . $page; + } + + print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print '
'; + print '
'; + print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; + print $langs->trans('Month') . ': '; + print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DatePropal", $_SERVER["PHP_SELF"], "p.date_valid", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) + { + $var = True; + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($result); + $var = ! $var; + + print ''; + print '\n"; + $societestatic->fetch($objp->socid); + print ''; + print '"; + print "\n"; + print '' . "\n"; + print ''; + print "\n"; + $i ++; + + if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; + } + } + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "
'; + $propalstatic->id=$objp->propalid; + $propalstatic->ref=$objp->ref; + print $propalstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).''; + print dol_print_date($db->jdate($objp->date_valid), 'dayhour') . "" . $objp->qty . "' . price($objp->amount) . '' . $propalstatic->LibStatut($objp->statut, 5) . '
' . $langs->trans('Total') . '' . $total_qty . '' . price($total_ht) . '
"; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 3e3eb4c28a7..2ddc9f29464 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -38,13 +38,13 @@ class MouvementStock extends CommonObject * @var string Name of table without prefix where object is stored */ public $table_element = 'stock_mouvement'; - + public $product_id; public $warehouse_id; public $qty; public $type; - + public $tms = ''; public $datem = ''; public $price; @@ -54,8 +54,8 @@ class MouvementStock extends CommonObject public $origintype; public $inventorycode; public $batch; - - + + /** * Constructor @@ -67,7 +67,7 @@ class MouvementStock extends CommonObject $this->db = $db; } - + /** * Add a movement of stock (in one direction only) * @@ -173,7 +173,7 @@ class MouvementStock extends CommonObject { $tmparray=dol_getdate($eatby, true); $eatbywithouthour=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility + if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility { // If found and eatby/sellby defined into table and provided and differs, return error $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatby, 'dayhour')); @@ -201,7 +201,7 @@ class MouvementStock extends CommonObject $this->errors = $productlot->errors; $this->db->rollback(); return -5; - } + } } } if ($obj->sellby) @@ -241,7 +241,7 @@ class MouvementStock extends CommonObject } } } - + $i++; } } @@ -270,7 +270,7 @@ class MouvementStock extends CommonObject return -1; } } - + // Define if we must make the stock change (If product type is a service or if stock is used also for services) $movestock=0; if ($product->type != Product::TYPE_SERVICE || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1; @@ -297,7 +297,7 @@ class MouvementStock extends CommonObject $this->errors[] = $langs->trans('qtyToTranferLotIsNotEnough'); $this->db->rollback(); return -8; - } + } } else { @@ -310,8 +310,8 @@ class MouvementStock extends CommonObject return -8; } } - } - + } + if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after { if(!empty($this->origin)) { // This is set by caller for tracking reason @@ -467,7 +467,7 @@ class MouvementStock extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.", "; $sql.= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql.= " WHERE rowid = ".$fk_product; - + dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) @@ -476,7 +476,7 @@ class MouvementStock extends CommonObject $error = -4; } } - + // If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine // having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot. $sql="DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)"; @@ -511,7 +511,7 @@ class MouvementStock extends CommonObject } } - + /** * Load object in memory from the database @@ -523,7 +523,7 @@ class MouvementStock extends CommonObject public function fetch($id) { dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.tms,"; @@ -548,20 +548,20 @@ class MouvementStock extends CommonObject //} else { $sql .= ' AND t.rowid = ' . $id; //} - + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); if ($numrows) { $obj = $this->db->fetch_object($resql); - + $this->id = $obj->rowid; - + $this->product_id = $obj->fk_product; $this->warehouse_id = $obj->fk_entrepot; $this->qty = $obj->value; $this->type = $obj->type_mouvement; - + $this->tms = $this->db->jdate($obj->tms); $this->datem = $this->db->jdate($obj->datem); $this->price = $obj->price; @@ -574,18 +574,18 @@ class MouvementStock extends CommonObject $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); } - + // Retrieve all extrafields for invoice // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $this->fetch_optionals($this->id,$extralabels); - + // $this->fetch_lines(); - + $this->db->free($resql); - + if ($numrows) { return 1; } else { @@ -594,13 +594,13 @@ class MouvementStock extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - + return - 1; } } - - - + + + /** * Create movement in database for all subproducts @@ -675,7 +675,7 @@ class MouvementStock extends CommonObject function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='', $eatby='', $sellby='', $batch='', $id_product_batch=0) { global $conf; - + $skip_batch = empty($conf->productbatch->enabled); return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, '', $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); @@ -756,7 +756,7 @@ class MouvementStock extends CommonObject /** * Create or update batch record (update table llx_product_batch). No check is done here, done by parent. * - * @param array|int $dluo Could be either + * @param array|int $dluo Could be either * - int if row id of product_batch table * - or complete array('fk_product_stock'=>, 'batchnumber'=>) * @param int $qty Quantity of product with batch number. May be a negative amount. @@ -765,13 +765,13 @@ class MouvementStock extends CommonObject private function createBatch($dluo, $qty) { global $user; - + $pdluo=new Productbatch($this->db); $result=0; // Try to find an existing record with same batch number or id - if (is_numeric($dluo)) + if (is_numeric($dluo)) { $result=$pdluo->fetch($dluo); if (empty($pdluo->id)) @@ -782,21 +782,21 @@ class MouvementStock extends CommonObject $result = -2; } } - else if (is_array($dluo)) + else if (is_array($dluo)) { - if (isset($dluo['fk_product_stock'])) + if (isset($dluo['fk_product_stock'])) { $vfk_product_stock=$dluo['fk_product_stock']; $vbatchnumber = $dluo['batchnumber']; - + $result = $pdluo->find($vfk_product_stock,'','',$vbatchnumber); // Search on batch number only (eatby and sellby are deprecated here) } - else + else { dol_syslog(get_class($this)."::createBatch array param dluo must contain at least key fk_product_stock".$error, LOG_ERR); $result = -1; } - } + } else { dol_syslog(get_class($this)."::createBatch error invalid param dluo".$error, LOG_ERR); @@ -810,7 +810,7 @@ class MouvementStock extends CommonObject { //print "Avant ".$pdluo->qty." Apres ".($pdluo->qty + $qty)."
"; $pdluo->qty += $qty; - if ($pdluo->qty == 0) + if ($pdluo->qty == 0) { $result=$pdluo->delete($user,1); } else { @@ -824,7 +824,7 @@ class MouvementStock extends CommonObject $pdluo->eatby = $veatby; $pdluo->sellby = $vsellby; $pdluo->batch = $vbatchnumber; - + $result=$pdluo->create($user,1); if ($result < 0) { @@ -833,21 +833,21 @@ class MouvementStock extends CommonObject } } } - + return $result; } /** * Return Url link of origin object - * + * * @param int $fk_origin Id origin * @param int $origintype Type origin * @return string */ - function get_origin($fk_origin, $origintype) + function get_origin($fk_origin, $origintype) { $origin=''; - + switch ($origintype) { case 'commande': require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -888,20 +888,20 @@ class MouvementStock extends CommonObject } if (empty($origin) || ! is_object($origin)) return ''; - + if ($origin->fetch($fk_origin) > 0) { return $origin->getNomUrl(1); } return ''; } - + /** * Set attribute origin to object - * + * * @param string $origin_element type of element * @param int $origin_id id of element - * + * * @return void */ function setOrigin($origin_element, $origin_id) @@ -940,7 +940,7 @@ class MouvementStock extends CommonObject // There is no specific properties. All data into insert are provided as method parameter. } - + /** * Return a link (with optionaly the picto) * Use this->id,this->lastname, this->firstname @@ -962,7 +962,7 @@ class MouvementStock extends CommonObject $label = '' . $langs->trans("Movement") . ' '.$this->id.''; $label.= '
'; $label.= '' . $langs->trans('Label') . ': ' . $this->label; - $label.= '
' . $langs->trans('Qty') . ': ' .$this->qty; + $label.= '
' . $langs->trans('Qty') . ': ' .$this->qty; $label.= '
'; $link = 'id . $linkend; return $result; } - + /** * Return label statut * @@ -989,7 +989,7 @@ class MouvementStock extends CommonObject { return $this->LibStatut($mode); } - + /** * Renvoi le libelle d'un status donne * diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 01df409361c..2963f5e278d 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -946,7 +946,6 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print '

'; print_titre($langs->trans('AddNewProductStockWarehouse')); - //print '
'; print '
'; print ''; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 085af055f38..97f9ff41d54 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -187,7 +187,7 @@ if (empty($reshook)) if (! $error && !empty($object->id) > 0) { // Category association - $categories = GETPOST('categories'); + $categories = GETPOST('categories', 'array'); $result=$object->setCategories($categories); if ($result<0) { $langs->load("errors"); @@ -282,7 +282,7 @@ if (empty($reshook)) else setEventMessages($object->error, $object->errors, 'errors'); }else { // Category association - $categories = GETPOST('categories'); + $categories = GETPOST('categories', 'array'); $result=$object->setCategories($categories); if ($result < 0) { diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index 2600fbd02fc..70ac20680b6 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -195,7 +195,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
pGroup
(optional) indicates whether this is a group task (parent) - Numeric; 0 = normal task, 1 = standard group task, 2 = combined group task*
pParent
(required) identifies a parent pID, this causes this task to be a child of identified task. Numeric, top level tasks should have pParent set to 0
pOpen
(required) indicates whether a standard group task is open when chart is first drawn. Value must be set for all items but is only used by standard group tasks. Numeric, 1 = open, 0 = closed
-
pDepend
(optional) comma separated list of id's this task is dependent on. A line will be drawn from each listed task to this item
Each id can optionally be followed by a dependency type suffix. Valid values are:
'FS' - Finish to Start (default if suffix is omitted)
'SF' - Start to Finish
'SS' - Start to Start
'FF' - Finish to Finish
If present the suffix must be added directly to the id e.g. '123SS'
+
pDepend
(optional) comma separated list of id's this task is dependent on. A line will be drawn from each listed task to this item
Each id can optionally be followed by a dependency type suffix. Valid values are:
'FS' - Finish to Start (default if suffix is omitted)
'SF' - Start to Finish
'SS' - Start to Start
'FF' - Finish to Finish
If present the suffix must be added directly to the id e.g. '123SS'
pCaption
(optional) caption that will be added after task bar if CaptionType set to "Caption"
pNotes
(optional) Detailed task information that will be displayed in tool tip for this task
pGantt
(required) javascript JSGantt.GanttChart object from which to take settings. Defaults to "g" for backwards compatibility
diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 3ee3cf2593b..a36337c324d 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -259,7 +259,7 @@ if ($id > 0 || ! empty($ref)) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject,$langs->trans("DeleteATask"),$langs->trans("ConfirmDeleteATask"),"confirm_delete"); } - + if (! GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); @@ -286,14 +286,14 @@ if ($id > 0 || ! empty($ref)) } dol_banner_tab($task, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - + print '
'; print '
'; print ''; - + // Nb comments - print ''; @@ -307,46 +307,46 @@ if ($id > 0 || ! empty($ref)) print ''; dol_fiche_end(); - - + + print '
'; print '
'; - + // Add comment - + print ''; print ''; print ''; print ''; print ''; - + print '
'.$langs->trans("TaskNbComments").''; + print ''.$langs->trans("TaskNbComments").''; print $task->getNbComments(); print '
'; - + print ''; print ''; print ''; print ''; print ''; print "\n"; - + print ''; print ''; - + // Description print ''; - + print ''; print '
'.$langs->trans("Comments").'
'; - + $desc = ($_POST['comment_description']?$_POST['comment_description']:''); - + $doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%'); print $doleditor->Create(1); - + print ''; print ''; print '
'; - + // List of comments if(!empty($task->comments)) { // Default color for current user @@ -367,7 +367,7 @@ if ($id > 0 || ! empty($ref)) if($comment->fk_user == $user->id) { print '
 
'; } - + print '
'; print '
'; if (! empty($user->photo)) @@ -377,7 +377,7 @@ if ($id > 0 || ! empty($ref)) print $langs->trans('User').' : '.$userstatic->getNomUrl().'
'; print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec'); print '
'; // End comment-info - + print '
'; print '
'; print '
'; @@ -391,17 +391,17 @@ if ($id > 0 || ! empty($ref)) print '
'; // End comment-table print '
'; // End comment-right print '
'; // End comment - + if($comment->fk_user != $user->id) { print '
 
'; } print '
'; print '
'; // end 100p - + $first = false; } } - + print '
'; print '
'; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index d4029847534..3d834fe28b6 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -187,7 +187,7 @@ if ($id > 0 || ! empty($ref)) // Tabs for project $tab='tasks'; $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($projectstatic->public?'projectpub':'project')); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); $param=($mode=='mine'?'&mode=mine':''); @@ -272,8 +272,11 @@ if ($id > 0 || ! empty($ref)) print '
'; dol_fiche_end(); + + print '
'; } + // To verify role of users //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project //$arrayofuseridoftask=$object->getListContactId('internal'); diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 649e1efd575..f6f206f90ec 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -130,7 +130,8 @@ if ($object->id > 0) // Tabs for project $tab='tasks'; $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($projectstatic->public?'projectpub':'project')); + + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); $param=($mode=='mine'?'&mode=mine':''); @@ -215,6 +216,8 @@ if ($object->id > 0) print '
'; dol_fiche_end(); + + print '
'; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 13a8979ae91..87d949eb645 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -110,7 +110,7 @@ if ($object->id > 0) // Tabs for project $tab='tasks'; $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"), 0, ($projectstatic->public?'projectpub':'project')); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); $param=($mode=='mine'?'&mode=mine':''); // Project card @@ -194,6 +194,8 @@ if ($object->id > 0) print '
'; dol_fiche_end(); + + print '
'; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 1b43940029f..db56534f851 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -279,6 +279,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print '
'; + print '
'; print '
'; print '
'; @@ -468,6 +469,7 @@ if ($id > 0 || ! empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); print '
'; + print '
'; print '
'; print ''; @@ -490,8 +492,21 @@ if ($id > 0 || ! empty($ref)) } print ''; + // Description + print ''; + + print '
'.$langs->trans("Description").''; + print nl2br($object->description); + print '
'; + print '
'; + + print '
'; + + print '
'; + print ''; + // Progress declared - print ''; - - // Description - print ''; // Other attributes @@ -522,6 +532,10 @@ if ($id > 0 || ! empty($ref)) print '
'.$langs->trans("ProgressDeclared").''; + print '
'.$langs->trans("ProgressDeclared").''; if ($object->progress != '') { print $object->progress.' %'; @@ -506,12 +521,7 @@ if ($id > 0 || ! empty($ref)) if ($tmparray['total_duration'] > 0 && ! empty($object->planned_workload)) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; else print '0 %'; } - else print ''; - print '
'.$langs->trans("Description").''; - print nl2br($object->description); + else print ''.$langs->trans("WorkloadNotDefined").''; print '
'; print '
'; + print '
'; + + print '
'; + print '
'; dol_fiche_end(); } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 8b85c299fdc..b3bbccfcb4e 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -418,6 +418,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; } + else + { + print '
'; + } } } @@ -442,7 +446,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -450,7 +454,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; if (is_object($projectstatic->thirdparty)) { @@ -464,7 +468,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; print '
'; - print '
'; + print '
'; print ''; // Date start - Date end @@ -491,7 +495,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; // Progress declared - print ''; @@ -503,7 +507,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; else print '0 %'; } - else print ''; + else print ''.$langs->trans("WorkloadNotDefined").''; print ''; print '
'.$langs->trans("ProgressDeclared").''; + print '
'.$langs->trans("ProgressDeclared").''; print $object->progress.' %'; print '
'; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 9c89b516eff..550fa9a6898 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -238,13 +238,13 @@ else } } $morehtmlref.='
'; - + dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); print '
'; - + print '
'; - + print ''; // Type @@ -315,7 +315,7 @@ else print '
'; print '
'; - + dol_fiche_end(); } } @@ -364,16 +364,16 @@ else $fichinter = new Fichinter($db); $fichinter->fetch($element_id, $element_ref); $fichinter->fetch_thirdparty(); - - if (is_object($fichinter)) + + if (is_object($fichinter)) { $head=fichinter_prepare_head($fichinter); dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"), -1, 'intervention'); // Intervention card $linkback = ''.$langs->trans("BackToList").''; - - + + $morehtmlref='
'; // Ref customer //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -414,9 +414,9 @@ else } } $morehtmlref.='
'; - + dol_banner_tab($fichinter, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '&element='.$element, 0, '', '', 1); - + dol_fiche_end(); } } @@ -440,7 +440,7 @@ else { $element_prop = getElementProperties($resource_obj); - //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
'; + //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
'; $path = ''; if(strpos($resource_obj,'@')) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 45101a79d45..80d6799e278 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -490,7 +490,7 @@ if (empty($reshook)) } // Customer categories association - $custcats = GETPOST( 'custcats', 'array' ); + $custcats = GETPOST('custcats', 'array'); $object->setCategories($custcats, 'customer'); // Supplier categories association @@ -607,7 +607,7 @@ if (empty($reshook)) } // Customer categories association - $categories = GETPOST( 'custcats', 'array' ); + $categories = GETPOST('custcats', 'array'); $object->setCategories($categories, 'customer'); // Supplier categories association @@ -2484,10 +2484,10 @@ else $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; - // Tableau des substitutions - //$formmail->setSubstitFromObject($object); - $formmail->substit['__THIRDPARTY_NAME__']=$object->name; - $formmail->substit['__SIGNATURE__']=$user->signature; + // Array of substitutions + $formmail->setSubstitFromObject($object); + $formmail->substit['__THIRDPARTY_ID__']=$object->id; // substit in setSubstitFromObject was wrong for this one + $formmail->substit['__THIRDPARTY_NAME__']=$object->name; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8fa7081acad..55a328e2538 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1908,6 +1908,7 @@ class Societe extends CommonObject { $label.= '
' . $langs->trans('Name') . ': '. $this->name; if (! empty($this->name_alias)) $label.=' ('.$this->name_alias.')'; + $label.= '
' . $langs->trans('Email') . ': '. $this->email; } if (! empty($this->country_code)) $label.= '
' . $langs->trans('Country') . ': '. $this->country_code; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e23a457cea5..786e5a09890 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -575,7 +575,7 @@ if (GETPOST('delsoc')) // List of mass actions available $arrayofmassactions = array( -// 'presend'=>$langs->trans("SendByMail"), + 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); @@ -606,6 +606,16 @@ foreach(array(1,2,3,4,5,6) as $key) } } +if ($massaction == 'presend') +{ + $topicmail="SendEmail"; + $modelmail="thirdparty"; + $objecttmp=new Societe($db); + $trackid='thi'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; +} + if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index fda4eea65ea..1b3857fdbf1 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -115,7 +115,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action=''; + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -462,16 +470,19 @@ if (empty($reshook)) } } - // Action for direct print + // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='SUPPLIER_PROPOSAL_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromsupplierproposal'; + $trigger_name='PROPOSAL_SUPPLIER_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO'; $trackid='spr'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + // Actions to build doc + $upload_dir = $conf->supplier_proposal->dir_output; + $permissioncreate = $user->rights->supplier_proposal->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Go back to draft @@ -876,44 +887,6 @@ if (empty($reshook)) exit(); } - // Generation doc (depuis lien ou depuis cartouche doc) - else if ($action == 'builddoc' && $user->rights->supplier_proposal->creer) { - if (GETPOST('model')) { - $object->setDocModel($user, GETPOST('model')); - } - - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id','aZ09') ? GETPOST('lang_id','aZ09') : $object->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } - } - - // Remove file in doc form - else if ($action == 'remove_file' && $user->rights->supplier_proposal->creer) { - if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->supplier_proposal->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); - else - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); - } - } - // Set project else if ($action == 'classin' && $user->rights->supplier_proposal->creer) { $object->setProject($_POST['projectid']); @@ -1811,108 +1784,18 @@ if ($action == 'create') print '
'; } - /* - * Action presend - */ + // Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } - if ($action == 'presend') - { - $object->fetch_projet(); - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->supplier_proposal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; + // Presend form + $modelmail='supplier_proposal_send'; + $defaulttopic='SendAskRef'; + $diroutput = $conf->supplier_proposal->dir_output; + $trackid = 'spr'.$object->id; - // 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->thirdparty->default_lang; - - if (!empty($newlang)) - { - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->load('commercial'); - $outputlangs->load('supplier_proposal'); - } - - // 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, $object->error, $object->errors); - exit(); - } - $fileparams = dol_most_recent_file($conf->supplier_proposal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - } - - print '
'; - print '
'; - print '
'; - print load_fiche_titre($langs->trans('SendAskByMail')); - - dol_fiche_head(''); - - // Create form object - 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 = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - $formmail->trackid='spr'.$object->id; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'spr'.$object->id); - } - - $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('SendAskRef', '__SUPPLIERPROPREF__'); - - $formmail->withfile = 2; - $formmail->withbody = 1; - $formmail->withdeliveryreceipt = 1; - $formmail->withcancel = 1; - - // Tableau des substitutions - $formmail->setSubstitFromObject($object); - $formmail->substit['__SUPPLIERPROPREF__'] = $object->ref; - - // Tableau des parametres complementaires - $formmail->param['action'] = 'send'; - $formmail->param['models'] = 'supplier_proposal_send'; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id'] = $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)); - } - - print $formmail->get_form(); - - dol_fiche_end(); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 96d1079b92a..7ad6c0d1b82 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -418,100 +418,12 @@ if ($resql) if ($massaction == 'presend') { - $langs->load("mails"); + $topicmail="SendSupplierProposalRef"; + $modelmail="supplier_proposal_send"; + $objecttmp=new SupplierProposal($db); + $trackid='spro'.$object->id; - if (! GETPOST('cancel','alpha')) - { - $objecttmp=new SupplierProposal($db); - $listofselectedid=array(); - $listofselectedthirdparties=array(); - $listofselectedref=array(); - foreach($arrayofselected as $toselectid) - { - $result=$objecttmp->fetch($toselectid); - if ($result > 0) - { - $listofselectedid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; - } - } - } - - print ''; - - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', ''); - - $topicmail="SendProposalRef"; - $modelmail="propal_send"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='ord'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelected"); - if (count($listofselectedthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofselectedthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id']=join(',',$arrayofselected); - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php'; } if ($sall) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index a495290f47a..273c71d8e8c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -260,7 +260,7 @@ if (empty($reshook)) { } if (! empty($conf->categorie->enabled)) { // Categories association - $usercats = GETPOST( 'usercats', 'array' ); + $usercats = GETPOST('usercats', 'array'); $object->setCategories($usercats); } $db->commit(); @@ -478,7 +478,7 @@ if (empty($reshook)) { if (! $error && ! count($object->errors)) { // Then we add the associated categories - $categories = GETPOST( 'usercats', 'array' ); + $categories = GETPOST('usercats', 'array'); $object->setCategories($categories); } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 1dac2e1672b..d0a82972325 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -71,9 +71,10 @@ class UserGroup extends CommonObject /** * Charge un objet group avec toutes ces caracteristiques (except ->members array) * - * @param int $id id du groupe a charger - * @param string $groupname name du groupe a charger - * @return int <0 if KO, >0 if OK + * @param int $id Id of group to load + * @param string $groupname Name of group to load + * @param boolean $load_members Load all members of the group + * @return int <0 if KO, >0 if OK */ function fetch($id='', $groupname='', $load_members = true) { @@ -136,8 +137,9 @@ class UserGroup extends CommonObject /** * Return array of groups objects for a particular user * - * @param int $userid User id to search - * @return array Array of groups objects + * @param int $userid User id to search + * @param boolean $load_members Load all members of the group + * @return array Array of groups objects */ function listGroupsForUser($userid, $load_members = true) {