diff --git a/.gitignore b/.gitignore index 1ece034ae94..aa332681474 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ dolibarr_install.log upgrade.log doxygen_warnings.log /.project +/.vscode .DS_Store .idea *.iml diff --git a/ChangeLog b/ChangeLog index 891b27ba78f..8a80591f652 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ For Users: NEW: Stable module: Website NEW: Stable module: WebDAV NEW: Stable module: Module Builder +NEW: Stable module "Skype" has been replaced with module "Social Networks" to support more tools. NEW: Dolibarr can provide information in page title when multicompany is enabled of not, making Android application like DoliDroid able to provide native features for multicompany module. @@ -24,6 +25,40 @@ Following changes may create regressions for some external modules, but were nec +***** ChangeLog for 8.0.2 compared to 8.0.1 ***** +FIX: #8452 +FIX: #9043 +FIX: #9316 Error when listing invoices +FIX: #9317 +FIX: #9353 Bug: html error - div inside span on graphs +FIX: #9355 +FIX: #9393 inconsistency behaviour. option FACTURE_ENABLE_NEGATIVE_LINES +FIX: #9394 +FIX: #9396 +FIX: #9403 +FIX: #9412 +FIX: #9497 +FIX: Add paypal error message in alert email when online payment fails. +FIX: better compatibility with multicompany +FIX: capital must be empty and not 0 if undefined +FIX: character making error on bill list +FIX: Entering negative price on order. +FIX: Expedition not showing extrafields on creation. +FIX: Homepage links were using wrong topmenus +FIX: inconsistency behaviour on option FACTURE_ENABLE_NEGATIVE_LINES +FIX: invert mime type and name. +FIX: invoice popup hide localtax2 and 3 if not defined. +FIX: Lose filter on payment type or category after a sort on invoice list. +FIX: Maxi debug to allow to load chart of account with multicompany. +FIX: Missing translation in predefined email to membership renewal. +FIX: Mixing tickets of different thirdparties. +FIX: "Other ..." link so the "Back to" link works. +FIX: PDF address: handle when contact thirdparty is different from thirdparty of document +FIX: Problems with permissions of module to record payment of salaries +FIX: remove debug +FIX: Several fixes on the management of minimal amount for orders +FIX: wrong var name + ***** ChangeLog for 8.0.1 compared to 8.0.0 ***** FIX: #9258 FIX: #9328 diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 2eedcda8760..0e3b2c7513f 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -295,6 +295,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0; if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0; if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0; + if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0; // admin.lang if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0; if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0; diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index ca47dbc7b96..087f9957f16 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -63,9 +63,9 @@ if (! $sortorder) $sortorder = "ASC"; $arrayfields=array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>0), + 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); @@ -122,16 +122,34 @@ if (empty($reshook)) { $sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql'; - // FIXME Get the ADD rowid and pass it + num of comapny * 100 000 000 to run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value. + $offsetforchartofaccount = 0; + // Get the comment line '-- ADD CCCNNNNN to rowid...' to find CCCNNNNN (CCC is country num, NNNNN is id of accounting account) + // and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value. + // This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used. + $tmp = file_get_contents($sqlfile); + if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) + { + $offsetforchartofaccount += $reg[1]; + } + $offsetforchartofaccount+=($conf->entity * 100000000); - $result = run_sql($sqlfile, 1, 0, 1); + $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount); + + if ($result > 0) + { + setEventMessages($langs->trans("ChartLoaded"), null); + } + else + { + setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings'); + } } if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error++; } } else { - $error ++; + $error++; } } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index b0c3adb7edd..7cd1f1d11b2 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -761,7 +761,7 @@ class AccountancyCategory // extends CommonObject * Return list of personalized groups that are active * * @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups - * @return array Array of groups + * @return array|int Array of groups or -1 if error */ public function getCats($categorytype=-1) { @@ -818,7 +818,7 @@ class AccountancyCategory // extends CommonObject * * @param int $cat_id Id if personalized accounting group/category * @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts - * @return array Array of accounting accounts + * @return array|int Array of accounting accounts or -1 if error */ public function getCptsCat($cat_id, $predefinedgroupwhere='') { diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index a67fd457e11..0ddbaeb5026 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -35,7 +35,7 @@ class lettering extends BookKeeping * lettrageTiers * * @param int $socid Thirdparty id - * @return void + * @return int 1 OK, <0 error */ public function lettrageTiers($socid) { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 90f20ca323d..f3e4e4d0df8 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2019,52 +2019,47 @@ class Adherent extends CommonObject if ($mode == 0) { if ($statut == -1) return $langs->trans("MemberStatusDraft"); - if ($statut >= 1) - { + elseif ($statut >= 1) { if (! $date_end_subscription) return $langs->trans("MemberStatusActive"); elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate"); else return $langs->trans("MemberStatusPaid"); } - if ($statut == 0) return $langs->trans("MemberStatusResiliated"); + elseif ($statut == 0) return $langs->trans("MemberStatusResiliated"); } elseif ($mode == 1) { if ($statut == -1) return $langs->trans("MemberStatusDraftShort"); - if ($statut >= 1) - { + elseif ($statut >= 1) { if (! $date_end_subscription) return $langs->trans("MemberStatusActiveShort"); elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLateShort"); else return $langs->trans("MemberStatusPaidShort"); } - if ($statut == 0) return $langs->trans("MemberStatusResiliatedShort"); + elseif ($statut == 0) return $langs->trans("MemberStatusResiliatedShort"); } elseif ($mode == 2) { if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'),'statut0').' '.$langs->trans("MemberStatusDraftShort"); - if ($statut >= 1) - { + elseif ($statut >= 1) { if (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'),'statut1').' '.$langs->trans("MemberStatusActiveShort"); elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'),'statut3').' '.$langs->trans("MemberStatusActiveLateShort"); else return img_picto($langs->trans('MemberStatusPaid'),'statut4').' '.$langs->trans("MemberStatusPaidShort"); } - if ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'),'statut5').' '.$langs->trans("MemberStatusResiliatedShort"); + elseif ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'),'statut5').' '.$langs->trans("MemberStatusResiliatedShort"); } elseif ($mode == 3) { if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'),'statut0'); - if ($statut >= 1) - { + elseif ($statut >= 1) { if (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'),'statut1'); elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'),'statut3'); else return img_picto($langs->trans('MemberStatusPaid'),'statut4'); } - if ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'),'statut5'); + elseif ($statut == 0) return img_picto($langs->trans('MemberStatusResiliated'),'statut5'); } elseif ($mode == 4) { if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'),'statut0').' '.$langs->trans("MemberStatusDraft"); - if ($statut >= 1) - { + elseif ($statut >= 1) { if (! $date_end_subscription) return img_picto($langs->trans('MemberStatusActive'),'statut1').' '.$langs->trans("MemberStatusActive"); elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'),'statut3').' '.$langs->trans("MemberStatusActiveLate"); else return img_picto($langs->trans('MemberStatusPaid'),'statut4').' '.$langs->trans("MemberStatusPaid"); @@ -2074,8 +2069,7 @@ class Adherent extends CommonObject elseif ($mode == 5) { if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'),'statut0'); - if ($statut >= 1) - { + elseif ($statut >= 1) { if (! $date_end_subscription) return ''.$langs->trans("MemberStatusActiveShort").' '.img_picto($langs->trans('MemberStatusActive'),'statut1'); elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLateShort").' '.img_picto($langs->trans('MemberStatusActiveLate'),'statut3'); else return ''.$langs->trans("MemberStatusPaidShort").' '.img_picto($langs->trans('MemberStatusPaid'),'statut4'); @@ -2085,8 +2079,7 @@ class Adherent extends CommonObject elseif ($mode == 6) { if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'),'statut0'); - if ($statut >= 1) - { + if ($statut >= 1) { if (! $date_end_subscription) return ''.$langs->trans("MemberStatusActive").' '.img_picto($langs->trans('MemberStatusActive'),'statut1'); elseif ($date_end_subscription < time()) return ''.$langs->trans("MemberStatusActiveLate").' '.img_picto($langs->trans('MemberStatusActiveLate'),'statut3'); else return ''.$langs->trans("MemberStatusPaid").' '.img_picto($langs->trans('MemberStatusPaid'),'statut4'); @@ -2107,7 +2100,7 @@ class Adherent extends CommonObject // phpcs:enable global $conf; - $this->nb=array(); + $this->nb = array(); $sql = "SELECT count(a.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 842c8d01470..8215bdbe0b1 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -356,7 +356,7 @@ print ''."\n"; print ''.$langs->trans("AGENDA_DEFAULT_VIEW").''."\n"; print ' '."\n"; print ''."\n"; -$tmplist=array('show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); +$tmplist=array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW); print ''."\n"; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f7242ee43bc..0f1f88f8c42 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -766,7 +766,13 @@ else // Web - print ''.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . ''; + print ''.$langs->trans("Web").''; + $arrayofurl = preg_split('/\s/', $conf->global->MAIN_INFO_SOCIETE_WEB); + foreach($arrayofurl as $urltoshow) + { + if ($urltoshow) print dol_print_url($urltoshow,'_blank',80); + } + print ''; // Barcode if (! empty($conf->barcode->enabled)) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 0c25f3a5bd8..b31a1972dd1 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -951,7 +951,6 @@ if (empty($id)) print $langs->trans("DictionaryDesc"); print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; } -print "
\n"; $param = '&id='.urlencode($id); @@ -1016,6 +1015,13 @@ if ($id) print ''; print ''; + if ($id == 10 && empty($conf->global->FACTURE_TVAOPTION)) + { + print info_admin($langs->trans("VATIsUsedIsOff", $langs->transnoentities("Setup"), $langs->transnoentities("CompanyFoundation"))); + } + + print "
\n"; + // Form to add a new line if ($tabname[$id]) { diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 2f64793c28b..be9859c1beb 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -89,6 +89,14 @@ print '
'; // Show info setup module print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); + +/* +$nbofactivatedmodules=count($conf->modules); +$moreinfo=$langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1), count($modules)); +if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); +print '
'.$moreinfo; +*/ + if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { $langs->load("errors"); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 89f0f028e1e..7c19f883210 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -272,14 +272,13 @@ $dirins_ok=(dol_is_dir($dirins)); $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('',$langs->trans("Setup"),$help_url, '', '', '', $morejs, $morecss, 0, 0); -$arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); -$arrayofwarnings=array(); // Array of warning each module want to show when activated -$arrayofwarningsext=array(); // Array of warning each module want to show when we activate an external module // Search modules dirs $modulesdir = dolGetModulesDirs(); - +$arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']'); +$arrayofwarnings=array(); // Array of warning each module want to show when activated +$arrayofwarningsext=array(); // Array of warning each module want to show when we activate an external module $filename = array(); $modules = array(); $orders = array(); @@ -847,6 +846,8 @@ if ($mode == 'common') dol_fiche_end(); + print '
'; + // Show warning about external users print info_admin(showModulesExludedForExternal($modules))."\n"; @@ -1063,7 +1064,7 @@ if ($mode == 'develop') //print ''; print '
'; print ''; - print ''.$langs->trans("TryToUseTheModuleBuilder").''; + print ''.$langs->trans("TryToUseTheModuleBuilder", $langs->transnoentitiesnoconv("ModuleBuilder")).''; print ''.$langs->trans("SeeTopRightMenu").''; print ''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 5bfda4f2c9c..fb9f2dd374e 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -342,7 +342,7 @@ if ($mode == 'test' && $user->admin) $langs->load($driver); $printer = new $classname($db); //print '
'.print_r($printer, true).'
'; - if (count($printer->getlist_available_printers())) { + if (count($printer->getlistAvailablePrinters())) { if ($printer->listAvailablePrinters()==0) { print $printer->resprint; } else { diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 76b3cf76b57..0dba6ea6700 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -67,6 +67,8 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'', $conf->entity); + + dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", $_POST["MAIN_INVERT_SENDER_RECIPIENT"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'', $conf->entity); @@ -572,31 +574,36 @@ else // Show print ""; print ''; - //Desc + // Hide Desc print ''.$langs->trans("HideDescOnPDF").''; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1); print ''; - //Ref + // Hide Ref print ''.$langs->trans("HideRefOnPDF").''; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1); print ''; - //Details + // Hide Details print ''.$langs->trans("HideDetailsOnPDF").''; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1); print ''; + // Invert sender and recipient + print ''.$langs->trans("SwapSenderAndRecipientOnPDF").''; + print yn($conf->global->MAIN_INVERT_SENDER_RECIPIENT,1); + print ''; - print ''.$langs->trans("PlaceCustomerAddressToIsoLocation").''; + // Use French location + print ''.$langs->trans("PlaceCustomerAddressToIsoLocation").''; print yn($conf->global->MAIN_PDF_USE_ISO_LOCATION,1); print ''; - print ''.$langs->trans("ShowDetailsInPDFPageFoot").''; + print ''.$langs->trans("ShowDetailsInPDFPageFoot").''; print $arraydetailsforpdffoot[($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0)]; print ''; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php new file mode 100644 index 00000000000..9aba26b3fc4 --- /dev/null +++ b/htdocs/admin/socialnetworks.php @@ -0,0 +1,123 @@ + + * + * 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/admin/socialnetworks.php + * \ingroup socialnetworks + * \brief Page to setup the module Social Networks + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("admin", "errors")); + +if (! $user->admin) accessforbidden(); + +$type=array('yesno','texte','chaine'); + +$action = GETPOST('action','aZ09'); + + + +/* + * Actions + */ + +// Action activation d'un sous module du module adherent +if ($action == 'set') +{ + $result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } +} + +// Action desactivation d'un sous module du module adherent +if ($action == 'unset') +{ + $result=dolibarr_del_const($db, $_GET["name"], $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } +} + + +/* + * View + */ + +$help_url=''; + +llxHeader('',$langs->trans("SocialNetworkSetup"),$help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("SocialNetworkSetup"),$linkback,'title_setup'); + +//$head = socialnetworks_admin_prepare_head(); +$h=0; +$head = array(); +$head[$h][0] = DOL_URL_ROOT.'/admin/socialnetworks.php'; +$head[$h][1] = $langs->trans("Setup"); +$head[$h][2] = 'setup'; +$h++; + + +print '
'; + +dol_fiche_head($head, 'setup', '', 0, 'user'); + +print '
'; + +$arrayofsocialnetworks=array('skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook'); + +foreach($arrayofsocialnetworks as $snkey => $snlabel) +{ + $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); + if (! empty($conf->global->$consttocheck)) + { + //$link=img_picto($langs->trans("Active"),'tick').' '; + $link=''; + //$link.=$langs->trans("Disable"); + $link.=img_picto($langs->trans("Activated"),'switch_on'); + $link.=''; + } + else + { + $link=''; + //$link.=img_$langs->trans("Activate") + $link.=img_picto($langs->trans("Disabled"),'switch_off'); + $link.=''; + } + print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; +} + + +dol_fiche_end(); + +print '
'; + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 9c2ee62565d..99a07c17248 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -156,7 +156,8 @@ $i=0; foreach($_SESSION as $key => $val) { if ($i > 0) print ', '; - print $key.' => '.dol_escape_htmltag($val); + if (is_array($val)) print $key.' => array(...)'; + else print $key.' => '.dol_escape_htmltag($val); $i++; } print ''."\n"; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 0418830cce8..10cffafb9a9 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -337,7 +337,13 @@ if (! $error && $xml) $i++; $out.=''; $out.=''.$i.'' . "\n"; - $out.=''.$file['filename'].'' . "\n"; + $out.=''.$file['filename']; + $out.=PHP_OS; + if (! preg_match('/^win/i',PHP_OS)) { + $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.'/'.$file['filename']); + $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'); + } + $out.='' . "\n"; $out.=''.$file['expectedmd5'].'' . "\n"; $out.=''.$file['md5'].'' . "\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 596b795999d..dbd472af1d3 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -372,32 +372,32 @@ class Asset extends CommonObject if ($mode == 0 || $mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } elseif ($mode == 6) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } } diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index b976857a522..0102a5d88d6 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -52,7 +52,6 @@ class BlockedLogAuthority */ public function __construct($db) { - $this->db = $db; } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index dab99d80bc9..eb2070d703a 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -46,6 +46,9 @@ class BlockedLog */ public $entity; + /** + * @var string Error message + */ public $error = ''; /** diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index ce3324505eb..44b209e4371 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -44,6 +44,7 @@ $origin = GETPOST('origin','alpha'); $catorigin = GETPOST('catorigin','int'); $type = GETPOST('type','alpha'); $urlfrom = GETPOST('urlfrom','alpha'); +$backtopage = GETPOST('backtopage','alpha'); $socid=GETPOST('socid','int'); $label=GETPOST('label'); @@ -173,6 +174,11 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr header("Location: ".$urlfrom); exit; } + elseif ($backtopage) + { + header("Location: ".$backtopage); + exit; + } else if ($idProdOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); @@ -232,8 +238,9 @@ if ($user->rights->categorie->creer) print ''; print ''; print ''; - print ''; + print ''; print ''; + print ''; if ($origin) print ''; if ($catorigin) print ''; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index e634da4fe80..18112f13eba 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -65,8 +65,11 @@ $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css') llxHeader('',$title,'','',0,0,$arrayofjs,$arrayofcss); +$newcardbutton = ''.$langs->trans("NewCategory").''; +$newcardbutton.= ''; +$newcardbutton.= ''; -print load_fiche_titre($title); +print load_fiche_titre($title, $newcardbutton); //print ''; //print ''; + // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } @@ -4486,6 +4487,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print "\n"; + // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0773e6eedc1..3ab5d84bfdb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1982,7 +1982,8 @@ class Facture extends CommonInvoice if (! dol_delete_file($file,0,0,0,$this)) // For triggers { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + $langs->load("errors"); + $this->error=$langs->trans("ErrorFailToDeleteFile",$file); $this->db->rollback(); return 0; } @@ -1991,7 +1992,8 @@ class Facture extends CommonInvoice { if (! dol_delete_dir_recursive($dir)) // For remove dir and meta { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + $langs->load("errors"); + $this->error=$langs->trans("ErrorFailToDeleteDir",$dir); $this->db->rollback(); return 0; } diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 619487e9574..31e362445f0 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -135,18 +135,17 @@ class PaymentTerm // extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_payment_term"); - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + //if (! $notrigger) { - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } + // // Call triggers + // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + // $interface=new Interfaces($this->db); + // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + // if ($result < 0) { $error++; $this->errors=$interface->errors; } + // // End call triggers + //} } // Commit or rollback @@ -311,21 +310,16 @@ class PaymentTerm // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + //if (! $error && ! $notrigger) { // Call triggers //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; //$interface=new Interfaces($this->db); //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } // End call triggers - } - } + //} // Commit or rollback if ($error) @@ -367,21 +361,16 @@ class PaymentTerm // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + //if (! $error && ! $notrigger) { //// Call triggers //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; //$interface=new Interfaces($this->db); //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + //} // Commit or rollback if ($error) @@ -439,12 +428,9 @@ class PaymentTerm // extends CommonObject $error++; } - if (! $error) - { - - - - } + //if (! $error) + //{ + //} unset($this->context['createfromclone']); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 804398232de..72cfa38e8c2 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -148,29 +148,29 @@ if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; $checkedtypetiers=0; $arrayfields=array( - 'f.facnumber'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'f.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), - 'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0), - 'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1), - 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1), - 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0: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), - 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), - 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), - 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), - 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), - 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), + 'f.facnumber'=>array('label'=>"Ref", 'checked'=>1), + 'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1), + 'f.type'=>array('label'=>"Type", 'checked'=>0), + 'f.date'=>array('label'=>"DateInvoice", 'checked'=>1), + 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 's.town'=>array('label'=>"Town", 'checked'=>1), + 's.zip'=>array('label'=>"Zip", 'checked'=>1), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), + 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1), + 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), + 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")), 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1")), - 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), - 'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0), - 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), - 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), + 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0), + 'rtp'=>array('label'=>"Rest", 'checked'=>0), + 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -422,22 +422,14 @@ if ($filtre) } if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref); if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer); -if ($search_type != '' && $search_type >= 0) -{ - if ($search_type == '0') $sql.=" AND f.type = 0"; // standard - if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement - if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note - if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit - if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma - if ($search_type == '5') $sql.=" AND f.type = 5"; // situation -} +if ($search_type != '') $sql.=" AND f.type IN (".$db->escape($search_type).")"; if ($search_project) $sql .= natural_search('p.ref', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_town) $sql.= natural_search('s.town', $search_town); if ($search_zip) $sql.= natural_search("s.zip",$search_zip); if ($search_state) $sql.= natural_search("state.nom",$search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; -if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; +if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); @@ -911,7 +903,8 @@ if ($resql) print "\n"; $projectstatic=new Project($db); - + $discount = new DiscountAbsolute($db); + if ($num > 0) { $i=0; @@ -928,6 +921,9 @@ if ($resql) $facturestatic->total_tva=$obj->total_vat; $facturestatic->total_ttc=$obj->total_ttc; $facturestatic->statut=$obj->fk_statut; + $facturestatic->total_ttc=$obj->total_ttc; + $facturestatic->paye=$obj->paye; + $facturestatic->fk_soc=$obj->fk_soc; $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); $facturestatic->note_public=$obj->note_public; $facturestatic->note_private=$obj->note_private; @@ -947,7 +943,12 @@ if ($resql) $totalcreditnotes = $facturestatic->getSumCreditNotesUsed(); $totaldeposits = $facturestatic->getSumDepositsUsed(); $totalpay = $paiement + $totalcreditnotes + $totaldeposits; - $remaintopay = $obj->total_ttc - $totalpay; + $remaintopay = $facturestatic->total_ttc - $totalpay; + if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { + $remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id); + $remaintopay = -$remaincreditnote; + $totalpay = $facturestatic->total_ttc - $remaintopay; + } print ''; if (! empty($arrayfields['f.facnumber']['checked'])) @@ -1071,11 +1072,20 @@ if ($resql) if (! empty($arrayfields['typent.code']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } + // Staff + if (! empty($arrayfields['staff.code']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Payment mode if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index c9794d9662e..1f0175bd370 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -135,15 +135,15 @@ class Cpaiement if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action to call a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + //if (!$notrigger) { - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers - } + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_CREATE',$user); + // if ($result < 0) $error++; + // // End call triggers + //} } // Commit or rollback @@ -278,15 +278,15 @@ class Cpaiement dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - if (!$error && !$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_MODIFY',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} // Commit or rollback if ($error) { @@ -316,17 +316,15 @@ class Cpaiement $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_DELETE',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - } + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_DELETE',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index b22d4d21e43..b4a21e198de 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -74,7 +74,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char } } -// Create payment +// Validate social contribution +/* if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer) { $db->begin(); @@ -111,6 +112,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->char $db->rollback(); } } +*/ /* @@ -150,12 +152,14 @@ if ($action == 'delete') /* * Validation confirmation of payment */ +/* if ($action == 'valide') { $facid = $_GET['facid']; print $form->formconfirm('card.php?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); } +*/ $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index dc45c9a4fb0..ea67873c2ee 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -82,7 +82,6 @@ class PaymentSalary extends CommonObject $this->db = $db; $this->element = 'payment_salary'; $this->table_element = 'payment_salary'; - return 1; } /** diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 409ee99aaae..9013edee195 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -25,7 +25,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -77,31 +77,18 @@ class Cchargesociales $error = 0; - // Clean parameters - - if (isset($this->libelle)) { - $this->libelle = trim($this->libelle); - } - if (isset($this->deductible)) { - $this->deductible = trim($this->deductible); - } - if (isset($this->active)) { - $this->active = trim($this->active); - } - if (isset($this->code)) { - $this->code = trim($this->code); - } - if (isset($this->fk_pays)) { - $this->fk_pays = trim($this->fk_pays); - } - if (isset($this->module)) { - $this->module = trim($this->module); - } - if (isset($this->accountancy_code)) { - $this->accountancy_code = trim($this->accountancy_code); - } - - + // Clean parameters + $this->trimParameters( + array( + 'libelle', + 'deductible', + 'active', + 'code', + 'fk_pays', + 'module', + 'accountancy_code', + ) + ); // Check parameters // Put here code to add control on parameters values @@ -143,7 +130,7 @@ class Cchargesociales if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - if (!$notrigger) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -151,7 +138,7 @@ class Cchargesociales //$result=$this->call_trigger('MYOBJECT_CREATE',$user); //if ($result < 0) $error++; //// End call triggers - } + //} } // Commit or rollback @@ -243,28 +230,17 @@ class Cchargesociales // Clean parameters - if (isset($this->libelle)) { - $this->libelle = trim($this->libelle); - } - if (isset($this->deductible)) { - $this->deductible = trim($this->deductible); - } - if (isset($this->active)) { - $this->active = trim($this->active); - } - if (isset($this->code)) { - $this->code = trim($this->code); - } - if (isset($this->fk_pays)) { - $this->fk_pays = trim($this->fk_pays); - } - if (isset($this->module)) { - $this->module = trim($this->module); - } - if (isset($this->accountancy_code)) { - $this->accountancy_code = trim($this->accountancy_code); - } - + $this->trimParameters( + array( + 'libelle', + 'deductible', + 'active', + 'code', + 'fk_pays', + 'module', + 'accountancy_code', + ) + ); // Check parameters @@ -290,7 +266,7 @@ class Cchargesociales dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - if (!$error && !$notrigger) { + //if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -298,7 +274,7 @@ class Cchargesociales //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} //// End call triggers - } + //} // Commit or rollback if ($error) { @@ -328,8 +304,8 @@ class Cchargesociales $this->db->begin(); - if (!$error) { - if (!$notrigger) { + //if (!$error) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -337,8 +313,8 @@ class Cchargesociales //$result=$this->call_trigger('MYOBJECT_DELETE',$user); //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} //// End call triggers - } - } + //} + //} if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; @@ -476,34 +452,33 @@ class Cchargesociales if ($mode == 0) { - $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 1) + elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 2) + elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 3) + elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); } - if ($mode == 4) + elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 5) + elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } } @@ -526,4 +501,20 @@ class Cchargesociales $this->module = ''; $this->accountancy_code = ''; } + + /** + * Trim object parameters + * @param string[] $parameters array of parameters to trim + * + * @return void + */ + private function trimParameters($parameters) + { + if (!is_array($parameters)) return; + foreach ($parameters as $parameter) { + if (isset($this->$parameter)) { + $this->$parameter = trim($this->$parameter); + } + } + } } diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 2ea82fb32c4..aa5786d0eb5 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -76,7 +76,6 @@ class ChargeSociales extends CommonObject function __construct($db) { $this->db = $db; - return 1; } /** @@ -431,8 +430,9 @@ class ChargeSociales extends CommonObject { // phpcs:enable global $langs; - $langs->load('customers'); - $langs->load('bills'); + + // Load translation files required by the page + $langs->loadLangs(array("customers","bills")); if ($mode == 0 || $mode == 1) { diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 9e1757fdc5a..babc7e1453a 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -186,6 +186,8 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id",'int'); $object->state_id = GETPOST("state_id",'int'); $object->skype = GETPOST("skype",'alpha'); + $object->twitter = GETPOST("twitter",'alpha'); + $object->facebook = GETPOST("facebook",'alpha'); $object->email = GETPOST("email",'alpha'); $object->phone_pro = GETPOST("phone_pro",'alpha'); $object->phone_perso = GETPOST("phone_perso",'alpha'); @@ -358,6 +360,8 @@ if (empty($reshook)) $object->email = GETPOST("email",'alpha'); $object->skype = GETPOST("skype",'alpha'); + $object->twitter = GETPOST("twitter",'alpha'); + $object->facebook = GETPOST("facebook",'alpha'); $object->phone_pro = GETPOST("phone_pro",'alpha'); $object->phone_perso = GETPOST("phone_perso",'alpha'); $object->phone_mobile = GETPOST("phone_mobile",'alpha'); @@ -658,13 +662,28 @@ else // Instant message and no email print ''; - print ''; + print ''; - // Skype - if (! empty($conf->skype->enabled)) + if (! empty($conf->socialnetworks->enabled)) { - print ''; - print ''; + // Skype + if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + { + print ''; + print ''; + } + // Twitter + if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + { + print ''; + print ''; + } + // Facebook + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print ''; + } } // Visibility @@ -914,11 +933,26 @@ else } print ''; - // Skype - if (! empty($conf->skype->enabled)) + if (! empty($conf->socialnetworks->enabled)) { - print ''; - print ''; + // Skype + if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + { + print ''; + print ''; + } + // Twitter + if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + { + print ''; + print ''; + } + // Facebook + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print ''; + } } // Visibility diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index f81c4eed4c3..b8cadaa4632 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -100,7 +100,7 @@ class Contact extends CommonObject public $state_code; // Code of department public $state; // Label of department - public $poste; // Position + public $poste; // Position public $socid; // fk_soc public $statut; // 0=inactif, 1=actif @@ -354,6 +354,8 @@ class Contact extends CommonObject $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; $sql .= ", skype='".$this->db->escape($this->skype)."'"; + $sql .= ", twitter='".$this->db->escape($this->twitter)."'"; + $sql .= ", facebook='".$this->db->escape($this->facebook)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); @@ -441,6 +443,16 @@ class Contact extends CommonObject $tmpobj->skype = $this->skype; $usermustbemodified++; } + if ($tmpobj->twitter != $this->twitter) + { + $tmpobj->twitter = $this->twitter; + $usermustbemodified++; + } + if ($tmpobj->facebook != $this->facebook) + { + $tmpobj->facebook = $this->facebook; + $usermustbemodified++; + } if ($usermustbemodified) { $result=$tmpobj->update($user, 0, 1, 1, 1); @@ -493,8 +505,8 @@ class Contact extends CommonObject global $conf; $dn=''; if ($mode==0) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; - if ($mode==1) $dn=$conf->global->LDAP_CONTACT_DN; - if ($mode==2) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS]; + elseif ($mode==1) $dn=$conf->global->LDAP_CONTACT_DN; + elseif ($mode==2) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS]; return $dn; } @@ -508,12 +520,12 @@ class Contact extends CommonObject function _load_ldap_info() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $info = array(); // Object classes - $info["objectclass"]=explode(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS); + $info["objectclass"]=explode(',', $conf->global->LDAP_CONTACT_OBJECT_CLASS); $this->fullname=$this->getFullName($langs); @@ -690,7 +702,7 @@ class Contact extends CommonObject $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement,"; $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype,"; + $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,"; $sql.= " c.import_key,"; @@ -756,6 +768,8 @@ class Contact extends CommonObject $this->email = $obj->email; $this->jabberid = $obj->jabberid; $this->skype = $obj->skype; + $this->twitter = $obj->twitter; + $this->facebook = $obj->facebook; $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; @@ -887,9 +901,9 @@ class Contact extends CommonObject if ($obj->nb) { if ($obj->element=='facture') $this->ref_facturation = $obj->nb; - if ($obj->element=='contrat') $this->ref_contrat = $obj->nb; - if ($obj->element=='commande') $this->ref_commande = $obj->nb; - if ($obj->element=='propal') $this->ref_propal = $obj->nb; + elseif ($obj->element=='contrat') $this->ref_contrat = $obj->nb; + elseif ($obj->element=='commande') $this->ref_commande = $obj->nb; + elseif ($obj->element=='propal') $this->ref_propal = $obj->nb; } } $this->db->free($resql); @@ -914,8 +928,8 @@ class Contact extends CommonObject $error=0; - $this->old_lastname = $obj->lastname; - $this->old_firstname = $obj->firstname; + $this->old_lastname = $obj->lastname; + $this->old_firstname = $obj->firstname; $this->db->begin(); @@ -1035,7 +1049,7 @@ class Contact extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; if ($obj->fk_user_creat) { $cuser = new User($this->db); @@ -1069,9 +1083,9 @@ class Contact extends CommonObject function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql.= " WHERE mc.email = '".$this->db->escape($this->email)."'"; - $sql.= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes + $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m"; + $sql.= " WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email)."' "; + $sql.= " AND m.entity IN (".getEntity($this->element).") AND mc.statut NOT IN (-1,0)"; // -1 error, 0 not sent, 1 sent with success $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0e0b0ee44f1..a2c937abc0a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1318,8 +1318,10 @@ else { $object->fetch_thirdparty(); - $result=$object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed - if ($result < 0) dol_print_error($db,$object->error); + $result=$object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed + if ($result < 0) { + dol_print_error($db,$object->error); + } $nbofservices=count($object->lines); @@ -1334,56 +1336,54 @@ else $head = contract_prepare_head($object); - $hselected = 0; + $hselected = 0; + $formconfirm = ''; - dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); + dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); - /* - * Confirmation de la suppression du contrat - */ - if ($action == 'delete') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1); + if ($action == 'delete') { + //Confirmation de la suppression du contrat + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1); + } elseif ($action == 'valid') { + //Confirmation de la validation + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { + $numref = $object->getNextNumRef($object->thirdparty); + } else { + $numref = $object->ref; + } + $text = $langs->trans('ConfirmValidateContract',$numref); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$text,"confirm_valid",'',0,1); + } elseif ($action == 'close') { + // Confirmation de la fermeture + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1); + } elseif ($action == 'activate') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ActivateAllOnContract"),$langs->trans("ConfirmActivateAllOnContract"),"confirm_activate",'',0,1); + } elseif ($action == 'clone') { + // Clone confirmation + $formquestion = array(array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - } - /* - * Confirmation de la validation - */ - if ($action == 'valid') - { - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) - { - $numref = $object->getNextNumRef($object->thirdparty); - } - else - { - $numref = $object->ref; - } + // Call Hook formConfirm + $parameters = array( + 'id' => $id, + //'lineid' => $lineid, + ); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - $text=$langs->trans('ConfirmValidateContract',$numref); + // Print form confirm + print $formconfirm; - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$text,"confirm_valid",'',0,1); - - } - - /* - * Confirmation de la fermeture - */ - if ($action == 'close') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1); - - } - if ($action == 'activate') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ActivateAllOnContract"),$langs->trans("ConfirmActivateAllOnContract"),"confirm_activate",'',0,1); - - } - - /* + /* * Contrat */ if (! empty($object->brouillon) && $user->rights->contrat->creer) @@ -1393,12 +1393,6 @@ else print ''; } - // Clone confirmation - if ($action == 'clone') { - $formquestion = array(array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); - print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - // Contract card $linkback = ''.$langs->trans("BackToList").''; @@ -1422,6 +1416,7 @@ else $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherContracts").')'; // Project if (! empty($conf->projet->enabled)) { @@ -1516,7 +1511,7 @@ else } - $colorb='666666'; + $colorb = '666666'; $arrayothercontracts=$object->getListOfContracts('others'); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a811f10f881..e76c7c34376 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -643,56 +643,49 @@ class Contrat extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $result = $this->db->fetch_array($resql); + $obj = $this->db->fetch_object($resql); - if ($result) + if ($obj) { - $this->id = $result["rowid"]; - $this->ref = (!isset($result["ref"]) || !$result["ref"]) ? $result["rowid"] : $result["ref"]; - $this->ref_customer = $result["ref_customer"]; - $this->ref_supplier = $result["ref_supplier"]; - $this->ref_ext = $result["ref_ext"]; - $this->statut = $result["statut"]; - $this->mise_en_service = $this->db->jdate($result["datemise"]); + $this->id = $obj->rowid; + $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; + $this->ref_customer = $obj->ref_customer; + $this->ref_supplier = $obj->ref_supplier; + $this->ref_ext = $obj->ref_ext; + $this->statut = $obj->statut; + $this->mise_en_service = $this->db->jdate($obj->datemise); - $this->date_contrat = $this->db->jdate($result["datecontrat"]); - $this->date_creation = $this->db->jdate($result["datecontrat"]); + $this->date_contrat = $this->db->jdate($obj->datecontrat); + $this->date_creation = $this->db->jdate($obj->datecontrat); - $this->fin_validite = $this->db->jdate($result["fin_validite"]); - $this->date_cloture = $this->db->jdate($result["date_cloture"]); + $this->fin_validite = $this->db->jdate($obj->fin_validite); + $this->date_cloture = $this->db->jdate($obj->date_cloture); - $this->user_author_id = $result["fk_user_author"]; + $this->user_author_id = $obj->fk_user_author; - $this->commercial_signature_id = $result["fk_commercial_signature"]; - $this->commercial_suivi_id = $result["fk_commercial_suivi"]; + $this->commercial_signature_id = $obj->fk_commercial_signature; + $this->commercial_suivi_id = $obj->fk_commercial_suivi; - $this->note_private = $result["note_private"]; - $this->note_public = $result["note_public"]; - $this->modelpdf = $result["model_pdf"]; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->modelpdf = $obj->model_pdf; - $this->fk_projet = $result["fk_projet"]; // deprecated - $this->fk_project = $result["fk_projet"]; + $this->fk_projet = $obj->fk_projet; // deprecated + $this->fk_project = $obj->fk_projet; - $this->socid = $result["fk_soc"]; - $this->fk_soc = $result["fk_soc"]; + $this->socid = $obj->fk_soc; + $this->fk_soc = $obj->fk_soc; - $this->extraparams = (array) json_decode($result["extraparams"], true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); - // Retreive all extrafields // fetch optionals attributes and labels $this->fetch_optionals(); - - /* - * Lines - */ - - $this->lines = array(); - + // Lines $result=$this->fetch_lines(); if ($result < 0) { @@ -1852,28 +1845,28 @@ class Contrat extends CommonObject if ($mode == 0) { if ($statut == 0) { return $langs->trans("ContractStatusDraft"); } - if ($statut == 1) { return $langs->trans("ContractStatusValidated"); } - if ($statut == 2) { return $langs->trans("ContractStatusClosed"); } + elseif ($statut == 1) { return $langs->trans("ContractStatusValidated"); } + elseif ($statut == 2) { return $langs->trans("ContractStatusClosed"); } } - if ($mode == 1) + elseif ($mode == 1) { if ($statut == 0) { return $langs->trans("ContractStatusDraft"); } - if ($statut == 1) { return $langs->trans("ContractStatusValidated"); } - if ($statut == 2) { return $langs->trans("ContractStatusClosed"); } + elseif ($statut == 1) { return $langs->trans("ContractStatusValidated"); } + elseif ($statut == 2) { return $langs->trans("ContractStatusClosed"); } } - if ($mode == 2) + elseif ($mode == 2) { if ($statut == 0) { return img_picto($langs->trans('ContractStatusDraft'),'statut0').' '.$langs->trans("ContractStatusDraft"); } - if ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'),'statut4').' '.$langs->trans("ContractStatusValidated"); } - if ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'),'statut6').' '.$langs->trans("ContractStatusClosed"); } + elseif ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'),'statut4').' '.$langs->trans("ContractStatusValidated"); } + elseif ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'),'statut6').' '.$langs->trans("ContractStatusClosed"); } } - if ($mode == 3) + elseif ($mode == 3) { if ($statut == 0) { return img_picto($langs->trans('ContractStatusDraft'),'statut0'); } - if ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'),'statut4'); } - if ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'),'statut6'); } + elseif ($statut == 1) { return img_picto($langs->trans('ContractStatusValidated'),'statut4'); } + elseif ($statut == 2) { return img_picto($langs->trans('ContractStatusClosed'),'statut6'); } } - if ($mode == 4 || $mode == 6 || $mode == 7) + elseif ($mode == 4 || $mode == 6 || $mode == 7) { $text=''; if ($mode == 4) @@ -1895,11 +1888,11 @@ class Contrat extends CommonObject $text.=($mode == 7?'':''); return $text; } - if ($mode == 5) + elseif ($mode == 5) { if ($statut == 0) { return $langs->trans("ContractStatusDraft").' '.img_picto($langs->trans('ContractStatusDraft'),'statut0'); } - if ($statut == 1) { return $langs->trans("ContractStatusValidated").' '.img_picto($langs->trans('ContractStatusValidated'),'statut4'); } - if ($statut == 2) { return $langs->trans("ContractStatusClosed").' '.img_picto($langs->trans('ContractStatusClosed'),'statut6'); } + elseif ($statut == 1) { return $langs->trans("ContractStatusValidated").' '.img_picto($langs->trans('ContractStatusValidated'),'statut4'); } + elseif ($statut == 2) { return $langs->trans("ContractStatusClosed").' '.img_picto($langs->trans('ContractStatusClosed'),'statut6'); } } } @@ -2123,7 +2116,7 @@ class Contrat extends CommonObject $sql.= " AND c.rowid = cd.fk_contrat"; $sql.= " AND cd.statut = 0"; } - if ($mode == 'expired') + elseif ($mode == 'expired') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; $sql.= $this->from; @@ -2389,7 +2382,7 @@ class Contrat extends CommonObject */ function createFromClone($socid = 0, $notrigger=0) { - global $db, $user, $langs, $conf, $hookmanager; + global $db, $user, $langs, $conf, $hookmanager, $extrafields; dol_include_once('/projet/class/project.class.php'); @@ -2398,6 +2391,7 @@ class Contrat extends CommonObject $error = 0; $this->fetch($this->id); + // Load dest object $clonedObj = clone $this; $clonedObj->socid = $socid; @@ -2408,8 +2402,23 @@ class Contrat extends CommonObject $objsoc->fetch($clonedObj->socid); - // $clonedObj->id=0; + // Clean data $clonedObj->statut = 0; + // Clean extrafields + if (is_array($clonedObj->array_options) && count($clonedObj->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($clonedObj->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + //var_dump($shortkey); var_dump($extrafields->attributes[$this->element]['unique'][$shortkey]); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($clonedObj->array_options[$key]); + } + } + } if (empty($conf->global->CONTRACT_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT . "/core/modules/contract/" . $conf->global->CONTRACT_ADDON . ".php")) { $this->error = 'ErrorSetupNotComplete'; @@ -2424,8 +2433,8 @@ class Contrat extends CommonObject $clonedObj->ref = $modContract->getNextValue($objsoc, $clonedObj); // get extrafields so they will be clone - foreach ( $this->lines as $line ) { - $line->fetch_optionals($line->rowid); + foreach ($this->lines as $line) { + $line->fetch_optionals($line->id); } // Create clone @@ -2628,50 +2637,50 @@ class ContratLigne extends CommonObjectLine if ($mode == 0) { if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); } - if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } - if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); } - if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLate"); } - if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } + elseif ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } + elseif ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); } + elseif ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLate"); } + elseif ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } } - if ($mode == 1) + elseif ($mode == 1) { if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); } - if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } - if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); } - if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); } - if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } + elseif ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } + elseif ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); } + elseif ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); } + elseif ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } } - if ($mode == 2) + elseif ($mode == 2) { if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } - if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } - if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); } - if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); } - if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } + elseif ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } + elseif ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); } + elseif ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); } + elseif ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } } - if ($mode == 3) + elseif ($mode == 3) { if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0',$moreatt); } - if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4',$moreatt); } - if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4',$moreatt); } - if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3',$moreatt); } - if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6',$moreatt); } + elseif ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4',$moreatt); } + elseif ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4',$moreatt); } + elseif ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3',$moreatt); } + elseif ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6',$moreatt); } } - if ($mode == 4) + elseif ($mode == 4) { if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } - if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } - if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLate"); } - if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); } - if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } + elseif ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } + elseif ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLate"); } + elseif ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); } + elseif ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } } - if ($mode == 5) + elseif ($mode == 5) { if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial").' '.img_picto($langs->trans('ServiceStatusInitial'),'statut0'); } - if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } - if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'),'statut4'); } - if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); } - if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'),'statut6'); } + elseif ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } + elseif ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'),'statut4'); } + elseif ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); } + elseif ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'),'statut6'); } } } @@ -3011,15 +3020,14 @@ class ContratLigne extends CommonObjectLine } } - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) { $error++; $this->db->rollback(); } - // End call triggers - } + if (! $error && ! $notrigger) { + // Call trigger + $result=$this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) { + $error++; + $this->db->rollback(); + } + // End call triggers } if (! $error) diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 063e3ecb228..f34eb1b5bdb 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -163,27 +163,26 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->contrat->creer) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->contrat->creer) { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -210,9 +209,12 @@ if ($id > 0 || ! empty($ref)) // Ligne info remises tiers print ''; + // Adds a line numbering column if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ''; // Description @@ -4911,6 +4913,9 @@ abstract class CommonObject } } + //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); + //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); + switch ($attributeType) { case 'int': @@ -4924,6 +4929,21 @@ abstract class CommonObject $new_array_options[$key] = null; } break; + case 'double': + $value = price2num($value); + if (!is_numeric($value) && $value!='') + { + dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); + $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); + return -1; + } + elseif ($value=='') + { + $new_array_options[$key] = null; + } + //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); + $new_array_options[$key] = $value; + break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') { @@ -5118,6 +5138,9 @@ abstract class CommonObject $attributeParam = $extrafields->attributes[$this->table_element]['param'][$key]; $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key]; + //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); + //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); + switch ($attributeType) { case 'int': @@ -5131,6 +5154,21 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + case 'double': + $value = price2num($value); + if (!is_numeric($value) && $value!='') + { + dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); + $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); + return -1; + } + elseif ($value=='') + { + $this->array_options["options_".$key] = null; + } + //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); + $this->array_options["options_".$key] = $value; + break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') { @@ -5329,7 +5367,7 @@ abstract class CommonObject if (!$required && $value == '') $value = '-1'; // TODO Must also support $moreparam - $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0); + $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } elseif (in_array($type,array('int','integer'))) { @@ -7288,7 +7326,7 @@ abstract class CommonObject $comment = new Comment($this->db); $result=$comment->fetchAllFor($this->element, $this->id); if ($result<0) { - $this->errors=array_merge($this->errors,$comment->errors); + $this->errors=array_merge($this->errors, $comment->errors); return -1; } else { $this->comments = $comment->comments; @@ -7305,4 +7343,20 @@ abstract class CommonObject { return count($this->comments); } + + /** + * Trim object parameters + * @param string[] $parameters array of parameters to trim + * + * @return void + */ + public function trimParameters($parameters) + { + if (!is_array($parameters)) return; + foreach ($parameters as $parameter) { + if (isset($this->$parameter)) { + $this->$parameter = trim($this->$parameter); + } + } + } } diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 6d4c32d82bb..5289ed882ff 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -61,9 +61,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; */ abstract class CommonStickerGenerator { - public $code; // Code of format - public $format; // Array with informations + + /** + * @var array format Array with informations + */ + public $format; // protected var $_Avery_Name = ''; // Nom du format de l'etiquette diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index db22d443c54..d6c768811c8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -35,12 +35,12 @@ class Conf /** \public */ //! To store properties found in conf file var $file; - + /** * @var DoliDB Database handler. */ public $db; - + //! To store properties found into database var $global; //! To store browser info @@ -182,7 +182,7 @@ class Conf if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; else if (in_array($partname,array('login','menus','substitutions','triggers','tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/'; else if (in_array($partname,array('models','theme'))) $value = '/'.$modulename.'/'; - else if (in_array($partname,array('sms'))) $value = $modulename; + else if (in_array($partname,array('sms'))) $value = '/'.$modulename.'/'; else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array } diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 085da06c754..4320446d7b5 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -56,7 +56,19 @@ class Cstate // extends CommonObject public $id; public $code_departement; - public $nom; + + /** + * @var string + * @deprecated + * @see name + */ + public $nom=''; + + /** + * @var string name + */ + public $name=''; + public $active; @@ -70,7 +82,6 @@ class Cstate // extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 9366cf6317b..db8ed461727 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -66,7 +66,6 @@ class Ctypent // extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 618716ce0e4..ad7b900b033 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -39,46 +39,46 @@ */ class DolGraph { - var $type=array(); // Array with type of each series. Example: array('bars', 'lines', ...) - var $mode='side'; // Mode bars graph: side, depth + public $type=array(); // Array with type of each series. Example: array('bars', 'lines', ...) + public $mode='side'; // Mode bars graph: side, depth private $_library='jflot'; // Graphic library to use (jflot, artichow) //! Array of data - var $data; // Data of graph: array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) - var $title; // Title of graph - var $cssprefix=''; // To add into css styles - var $width=380; - var $height=200; - var $MaxValue=0; - var $MinValue=0; - var $SetShading=0; + public $data; // Data of graph: array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) + public $title; // Title of graph + public $cssprefix=''; // To add into css styles + public $width=380; + public $height=200; + public $MaxValue=0; + public $MinValue=0; + public $SetShading=0; - var $PrecisionY=-1; + public $PrecisionY=-1; - var $horizTickIncrement=-1; - var $SetNumXTicks=-1; - var $labelInterval=-1; + public $horizTickIncrement=-1; + public $SetNumXTicks=-1; + public $labelInterval=-1; - var $hideXGrid=false; - var $hideYGrid=false; + public $hideXGrid=false; + public $hideYGrid=false; - var $Legend=array(); - var $LegendWidthMin=0; - var $showlegend=1; - var $showpointvalue=1; - var $showpercent=0; - var $combine=0; // 0.05 if you want to combine records < 5% into "other" - var $graph; // Objet Graph (Artichow, Phplot...) + public $Legend=array(); + public $LegendWidthMin=0; + public $showlegend=1; + public $showpointvalue=1; + public $showpercent=0; + public $combine=0; // 0.05 if you want to combine records < 5% into "other" + public $graph; // Objet Graph (Artichow, Phplot...) /** * @var string Error code (or message) */ public $error=''; - var $bordercolor; // array(R,G,B) - var $bgcolor; // array(R,G,B) - var $bgcolorgrid=array(255,255,255); // array(R,G,B) - var $datacolor; // array(array(R,G,B),...) + public $bordercolor; // array(R,G,B) + public $bgcolor; // array(R,G,B) + public $bgcolorgrid=array(255,255,255); // array(R,G,B) + public $datacolor; // array(array(R,G,B),...) private $stringtoshow; // To store string to output graph into HTML page diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 2ac2a51d2ed..436a708d312 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -117,7 +117,6 @@ class Events // extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c86bd3eff3f..07f6849e7ec 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1001,7 +1001,7 @@ class ExtraFields if (!$required && $value == '') $value = '-1'; // TODO Must also support $moreparam - $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0); + $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } elseif (in_array($type,array('int','integer'))) { diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index de4dc46ac90..c4ab50179d9 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -79,9 +79,7 @@ class Fiscalyear extends CommonObject $this->db = $db; $this->statuts_short = array(0 => 'Opened', 1 => 'Closed'); - $this->statuts = array(0 => 'Opened', 1 => 'Closed'); - - return 1; + $this->statuts = array(0 => 'Opened', 1 => 'Closed'); } /** diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 177b05850ed..149f1681725 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1108,8 +1108,8 @@ class Form else if (!is_array($selected)) $selected = array($selected); // Clean $filter that may contains sql conditions so sql code - if (function_exists('test_sql_and_script_inject')) { - if (test_sql_and_script_inject($filter, 3)>0) { + if (function_exists('testSqlAndScriptInject')) { + if (testSqlAndScriptInject($filter, 3)>0) { $filter =''; } } @@ -4829,6 +4829,10 @@ class Form $tmpthirdparty=new Societe($this->db); $defaulttx=get_default_tva($societe_vendeuse, (is_object($societe_acheteuse)?$societe_acheteuse:$tmpthirdparty), $idprod); $defaultnpr=get_default_npr($societe_vendeuse, (is_object($societe_acheteuse)?$societe_acheteuse:$tmpthirdparty), $idprod); + if (preg_match('/\((.*)\)/', $defaulttx, $reg)) { + $defaultcode=$reg[1]; + $defaulttx=preg_replace('/\s*\(.*\)/','',$defaulttx); + } if (empty($defaulttx)) $defaultnpr=0; } @@ -4928,18 +4932,17 @@ class Form * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. * @param datetime $adddateof Add a link "Date of invoice" using the following date. - * @return string|null Nothing or string if nooutput is 1 + * @return string|null Nothing or string if nooutput is 1 * @deprecated * @see form_date, select_month, select_year, select_dayofweek */ function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='') { // phpcs:enable - $retstring = $this->selectDate($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $disabled=0, $fullday='', $addplusone='', $adddateof=''); + $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); if (! empty($nooutput)) { return $retstring; } - print $retstring; return; } @@ -5730,7 +5733,7 @@ class Form * @param string $morecss Add more class to css styles * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. * @param string $placeholder String to use as placeholder - * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) + * @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string * @see selectArrayFilter, ajax_combobox in ajax.lib.php */ @@ -5832,7 +5835,7 @@ class Form * @param string $morecss Add more class to css styles * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. * @param string $placeholder String to use as placeholder - * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) + * @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string * @see selectArrayAjax, ajax_combobox in ajax.lib.php */ @@ -5949,55 +5952,76 @@ class Form * @param int $width Force width of select box. May be used only when using jquery couch. Example: 250, 95% * @param string $moreattrib Add more options on select component. Example: 'disabled' * @param string $elemtype Type of element we show ('category', ...) + * @param string $placeholder String to use as placeholder + * @param int $addjscombo Add js combo * @return string HTML multiselect string * @see selectarray */ - static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='',$elemtype='') + static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=1) { global $conf, $langs; $out = ''; + // Add code for jquery to use multiselect if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { - $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; - $out.="\n".' - '; + $out.="\n".' + '; } // Try also magic suggest @@ -6075,7 +6099,7 @@ class Form } if ($val['label']) { - $lis.='
  • '.dol_escape_htmltag($langs->trans($val['label'])).'
  • '; + $lis.='
  • '; $listcheckedstring.=(empty($val['checked'])?'':$key.','); } } @@ -6346,6 +6370,7 @@ class Form 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'), 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.facnumber as ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'), + 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'), 'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), @@ -6408,8 +6433,7 @@ class Form { $objp = $this->db->fetch_object($resqllist); - $var = ! $var; - print ''; + print ''; print ''; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index e01e1f2ad65..25a3973cbd8 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -48,7 +48,6 @@ class FormActions function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 22fa73741ce..8d8e65e5130 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -41,7 +41,6 @@ class FormAdmin function __construct($db) { $this->db = $db; - return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index c2c408801c4..eb08aab6de7 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -48,7 +48,6 @@ class FormBarCode function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 5c39bc0cef4..273a84cbc94 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -49,8 +49,6 @@ class FormCompany function __construct($db) { $this->db = $db; - - return 1; } diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 496d77f1f68..94747481cb0 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -46,7 +46,6 @@ class FormCron extends Form function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index c1bc479fc73..4a59e28f044 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -54,7 +54,6 @@ class FormFile { $this->db = $db; $this->numoffiles=0; - return 1; } @@ -128,11 +127,12 @@ class FormFile if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024; if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024; // Now $max and $maxphp are in Kb - if ($maxphp > 0) $max=min($max,$maxphp); + $maxmin = $max; + if ($maxphp > 0) $maxmin=min($max,$maxphp); - if ($max > 0) + if ($maxmin > 0) { - $out .= ''; + $out .= ''; } $out .= 'load('link'); $title = $langs->trans("LinkANewFile"); $out .= load_fiche_titre($title, null, null); @@ -213,19 +213,18 @@ class FormFile $out .= ''; $out .= '
    '; $out .= '
    '; - $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); - $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object); - $out .= "\n\n"; + $out .= "\n\n"; } + $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); + $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object); if (empty($res)) { print '
    '; print $out; print '
    '; } - print $hookmanager->resPrint; return 1; @@ -916,7 +915,7 @@ class FormFile if (! empty($file_list)) { $out=''."\n"; - print ''; @@ -159,9 +158,17 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { - print ''; + } - // Show filemanager tree (will be filled by call of ajax enablefiletreeajax.tpl.php that execute ajaxdirtree.php) + + + print ' + -
    '; @@ -170,6 +173,8 @@ foreach($fulltree as $key => $val) } +//print_barre_liste('', 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, 0, '', 0, $newcardbutton, '', 0, 1, 1); + print ''; print ''; + + print ''; } if (!empty($origin) && !empty($originid)) @@ -1270,10 +1311,41 @@ if ($id > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''; print ''; - print ''; + + if ($object->elementtype == 'task' && ! empty($conf->projet->enabled)) + { + print ''; + } + else + { + print ''; + } + print ''; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7b9caabb8a9..c175ad900ea 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1166,58 +1166,58 @@ class ActionComm extends CommonObject if ($mode == 0) { if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - else if ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; - else if ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; - else if ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; + elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; + elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; } - else if ($mode == 1) + elseif ($mode == 1) { if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - else if ($percent==0) return $langs->trans('StatusActionToDo'); - else if ($percent > 0 && $percent < 100) return $percent.'%'; - else if ($percent >= 100) return $langs->trans('StatusActionDone'); + elseif ($percent==0) return $langs->trans('StatusActionToDo'); + elseif ($percent > 0 && $percent < 100) return $percent.'%'; + elseif ($percent >= 100) return $langs->trans('StatusActionDone'); } - else if ($mode == 2) + elseif ($mode == 2) { if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable'); - else if ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo'); - else if ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '. $percent.'%'; - else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone'); + elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo'); + elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '. $percent.'%'; + elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone'); } - else if ($mode == 3) + elseif ($mode == 3) { if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'),'statut9'); - else if ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)','statut1'); - else if ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)','statut3'); - else if ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)','statut6'); + elseif ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)','statut1'); + elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)','statut3'); + elseif ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)','statut6'); } - else if ($mode == 4) + elseif ($mode == 4) { if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable'); - else if ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; - else if ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)'; - else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone').' (100%)'; + elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; + elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone').' (100%)'; } - else if ($mode == 5) + elseif ($mode == 5) { if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9'); - else if ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); - else if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); - else if ($percent >= 100) return $langs->trans('StatusActionDone').' '.img_picto($langs->trans('StatusActionDone'),'statut6'); + elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); + elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); + elseif ($percent >= 100) return $langs->trans('StatusActionDone').' '.img_picto($langs->trans('StatusActionDone'),'statut6'); } - else if ($mode == 6) + elseif ($mode == 6) { if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'),'statut9'); - else if ($percent==0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'),'statut1'); - else if ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%) '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); - else if ($percent >= 100) return $langs->trans('StatusActionDone').' (100%) '.img_picto($langs->trans('StatusActionDone'),'statut6'); + elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'),'statut1'); + elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%) '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); + elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%) '.img_picto($langs->trans('StatusActionDone'),'statut6'); } - else if ($mode == 7) + elseif ($mode == 7) { if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9'); - else if ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); - else if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); - else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6'); + elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); + elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); + elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6'); } return ''; @@ -1564,8 +1564,8 @@ class ActionComm extends CommonObject // Write file if ($format == 'vcal') $result=build_calfile($format,$title,$desc,$eventarray,$outputfiletmp); - if ($format == 'ical') $result=build_calfile($format,$title,$desc,$eventarray,$outputfiletmp); - if ($format == 'rss') $result=build_rssfile($format,$title,$desc,$eventarray,$outputfiletmp); + elseif ($format == 'ical') $result=build_calfile($format,$title,$desc,$eventarray,$outputfiletmp); + elseif ($format == 'rss') $result=build_rssfile($format,$title,$desc,$eventarray,$outputfiletmp); if ($result >= 0) { diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 63773661cbd..6c9632d83e5 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -189,32 +189,32 @@ class ActionCommReminder extends CommonObject if ($mode == 0 || $mode == 1) { if ($status == 1) return $langs->trans('Done'); - if ($status == 0) return $langs->trans('ToDo'); + elseif ($status == 0) return $langs->trans('ToDo'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); - if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); + elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Done'),'statut4'); - if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5'); + elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); - if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); + elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); - if ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); + elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); } elseif ($mode == 6) { if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); - if ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); + elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); } } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 178e4bfb6d7..b6e02861c9b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -83,7 +83,7 @@ $resourceid=GETPOST("resourceid","int"); $year=GETPOST("year","int")?GETPOST("year","int"):date("Y"); $month=GETPOST("month","int")?GETPOST("month","int"):date("m"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); -$day=GETPOST("day","int")?GETPOST("day","int"):0; +$day=GETPOST("day","int")?GETPOST("day","int"):date("d"); $pid=GETPOST("projectid","int",3); $status=GETPOST("status",'aZ09'); // status may be 0, 50, 100, 'todo' $type=GETPOST("type",'az09'); @@ -101,20 +101,23 @@ else if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); -if ($action == 'default') + +$defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +$defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW); +if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=$defaultview; +if ($action == 'default') // When action is default, we want a calendar view and not the list { - $action = ((! empty($conf->global->AGENDA_DEFAULT_VIEW) && $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month'); + $action = (($defaultview != 'show_list') ? $defaultview : 'show_month'); } -if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week') { +if (GETPOST('viewcal','none') && GETPOST('action','alpha') != 'show_day' && GETPOST('action','alpha') != 'show_week') { $action='show_month'; $day=''; -} // View by month -if (GETPOST('viewweek') || $action == 'show_week') { +} // View by month +if (GETPOST('viewweek','none') || GETPOST('action','alpha') == 'show_week') { $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); -} // View by week -if (GETPOST('viewday') || $action == 'show_day') { +} // View by week +if (GETPOST('viewday','none') || GETPOST('action','alpha') == 'show_day') { $action='show_day'; $day=($day?$day:date("d")); -} // View by day +} // View by day // Load translation files required by the page $langs->loadLangs(array('agenda', 'other', 'commercial')); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 5874a7b855c..596c3cb3c5b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -666,6 +666,8 @@ if ($object->id > 0) */ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { + $langs->load("propal"); + $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; $sql.= ", p.tva as total_tva"; $sql.= ", p.total as total_ttc"; @@ -674,7 +676,7 @@ if ($object->id > 0) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('propal').")"; $sql.= " ORDER BY p.datep DESC"; $resql=$db->query($sql); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 469db6f2a54..a2e63da99cc 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -874,7 +874,7 @@ else } } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlright=''; $nbtry = $nbok = 0; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 7a0d758ae17..bb6ac93d1c2 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -530,6 +530,81 @@ class Mailing extends CommonObject } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("ShowEmailing") . ''; + $label.= '
    '; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowEmailing"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action; + $hookmanager->initHooks(array('emailingdao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + /** * Return label of status of emailing (draft, validated, ...) * diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 5087698b9ab..133a354723f 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -35,15 +35,15 @@ $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || GETPOST('button_search','alpha') || GETPOST('button_removefilter','alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="m.date_creat"; -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$sref=GETPOST("sref", "alpha"); +$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_ref=GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); $filteremail=GETPOST('filteremail','alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -59,6 +59,53 @@ $fieldstosearchall = array( 'm.titre'=>'Ref', ); +$object = new Mailing($db); + + + +/* + * Actions + */ + +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + 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 + { + /*foreach($object->fields as $key => $val) + { + $search[$key]=''; + }*/ + $search_ref = ''; + $search_all = ''; + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + /*$objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ +} /* @@ -76,8 +123,8 @@ if ($filteremail) $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql.= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; $sql.= " AND mc.email = '".$db->escape($filteremail)."'"; - if ($sref) $sql.= " AND m.rowid = '".$db->escape($sref)."'"; - if ($sall) $sql.= " AND (m.titre like '%".$db->escape($sall)."%' OR m.sujet like '%".$db->escape($sall)."%' OR m.body like '%".$db->escape($sall)."%')"; + if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="m.rowid"; $sql.= $db->order($sortfield,$sortorder); @@ -88,8 +135,8 @@ else $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql.= " WHERE m.entity = ".$conf->entity; - if ($sref) $sql.= " AND m.rowid = '".$db->escape($sref)."'"; - if ($sall) $sql.= " AND (m.titre like '%".$db->escape($sall)."%' OR m.sujet like '%".$db->escape($sall)."%' OR m.body like '%".$db->escape($sall)."%')"; + if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="m.rowid"; $sql.= $db->order($sortfield,$sortorder); @@ -115,7 +162,7 @@ if ($result) $i = 0; - $param = "&sall=".urlencode($sall); + $param = "&search_all=".urlencode($search_all); if ($filteremail) $param.='&filteremail='.urlencode($filteremail); print ''; @@ -135,11 +182,11 @@ if ($result) print ''; print ''; // Title print ''; print ''; if (! $filteremail) print ''; @@ -169,16 +216,22 @@ if ($result) { $obj = $db->fetch_object($result); - + $email->id = $obj->rowid; + $email->ref = $obj->rowid; print ""; - print ''; + + print ''; + print ''; // Date creation + print ''; + // Nb of email if (! $filteremail) { @@ -196,9 +249,11 @@ if ($result) print $nbemail; print ''; } + // Last send print ''; print ''; + // Status print ''; + print ''; + print "\n"; $i++; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 30fa8d74a8d..cba114714e6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1848,7 +1848,7 @@ if ($action == 'create') $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherProposals").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherProposals").')'; // Project if (! empty($conf->projet->enabled)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 45e139c0b4f..2160e77cc2d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018 Frédéric France * * 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 @@ -1032,6 +1033,7 @@ class Propal extends CommonObject // Add linked object (deprecated, use ->linkedObjectsIds instead) if (! $error && $this->origin && $this->origin_id) { + dol_syslog('Deprecated use of linked object, use ->linkedObjectsIds instead', LOG_WARNING); $ret = $this->add_object_linked(); if (! $ret) dol_print_error($this->db); } @@ -1104,13 +1106,6 @@ class Propal extends CommonObject } } - // Add linked object - if (! $error && $this->origin && $this->origin_id) - { - $ret = $this->add_object_linked(); - if (! $ret) dol_print_error($this->db); - } - // Set delivery address if (! $error && $this->fk_delivery_address) { @@ -3174,18 +3169,18 @@ class Propal extends CommonObject $statuttrans=''; if ($statut==self::STATUS_DRAFT) $statuttrans='statut0'; - if ($statut==self::STATUS_VALIDATED) $statuttrans='statut1'; - if ($statut==self::STATUS_SIGNED) $statuttrans='statut3'; - if ($statut==self::STATUS_NOTSIGNED) $statuttrans='statut5'; - if ($statut==self::STATUS_BILLED) $statuttrans='statut6'; + elseif ($statut==self::STATUS_VALIDATED) $statuttrans='statut1'; + elseif ($statut==self::STATUS_SIGNED) $statuttrans='statut3'; + elseif ($statut==self::STATUS_NOTSIGNED) $statuttrans='statut5'; + elseif ($statut==self::STATUS_BILLED) $statuttrans='statut6'; if ($mode == 0) return $this->labelstatut[$statut]; - if ($mode == 1) return $this->labelstatut_short[$statut]; - if ($mode == 2) return img_picto($this->labelstatut_short[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - if ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - if ($mode == 4) return img_picto($this->labelstatut[$statut],$statuttrans).' '.$this->labelstatut[$statut]; - if ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans); - if ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans); + elseif ($mode == 1) return $this->labelstatut_short[$statut]; + elseif ($mode == 2) return img_picto($this->labelstatut_short[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; + elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); + elseif ($mode == 4) return img_picto($this->labelstatut[$statut],$statuttrans).' '.$this->labelstatut[$statut]; + elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans); + elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans); } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0dd266ef186..ced62e9d27a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1989,7 +1989,7 @@ if ($action == 'create' && $user->rights->commande->creer) $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherOrders").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherOrders").')'; // Project if (! empty($conf->projet->enabled)) { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index b58619b66a2..2325d30a26a 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -60,7 +60,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('bankcard','globalcard')); /* * Actions diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 3bd5997506e..c45067740af 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1716,7 +1716,11 @@ class AccountLine extends CommonObject public $fk_account; // Id of bank account public $bank_account_label; // Label of bank account - public $emetteur; + /** + * Issuer + * @var Societe + */ + public $emetteur; /** * Constructor diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 2389d1fec77..9bd00c81894 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -49,6 +49,9 @@ $result=restrictedArea($user,'banque',$id,'bank_account&bank_account','','',$fie $vline=isset($_GET["vline"])?$_GET["vline"]:$_POST["vline"]; $page=isset($_GET["page"])?$_GET["page"]:0; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('banktreso','globalcard')); + /* * View */ @@ -130,6 +133,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Remainder to pay in future + $sqls = array(); // Customer invoices $sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; @@ -138,79 +142,55 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid - $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice - $sql.= " ORDER BY dlr ASC"; + $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Supplier invoices - $sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; - $sql2.= " s.rowid as socid, s.nom as name, s.fournisseur"; - $sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; - $sql2.= " WHERE ff.entity = ".$conf->entity; - $sql2.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid - $sql2.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice - $sql2.= " ORDER BY dlr ASC"; + $sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; + $sql.= " s.rowid as socid, s.nom as name, s.fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; + $sql.= " WHERE ff.entity = ".$conf->entity; + $sql.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid + $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Social contributions - $sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; - $sql3.= ", cs.fk_account"; - $sql3.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; - $sql3.= " WHERE cs.entity = ".$conf->entity; - $sql3.= " AND cs.paye = 0"; // Not paid - $sql3.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution - $sql3.= " ORDER BY dlr ASC"; + $sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; + $sql.= ", cs.fk_account"; + $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; + $sql.= " WHERE cs.entity = ".$conf->entity; + $sql.= " AND cs.paye = 0"; // Not paid + $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; + + // others sql + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook) and isset($hookmanager->resArray['sql'])){ + $sqls[] = $hookmanager->resArray['sql']; + } $error=0; $tab_sqlobjOrder=array(); $tab_sqlobj=array(); - // List customer invoices - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - for ($i = 0;$i < $num;$i++) - { - $sqlobj = $db->fetch_object($result); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($result); - } - else $error++; - - // List supplier invoices - $result2=$db->query($sql2); - if ($result2) - { - $num = $db->num_rows($result2); - for ($i = 0;$i < $num;$i++) - { - $sqlobj = $db->fetch_object($result2); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($result2); - } - else $error++; - - // List social contributions - $result3=$db->query($sql3); - if ($result3) - { - $num = $db->num_rows($result3); - - for ($i = 0;$i < $num;$i++) - { - $sqlobj = $db->fetch_object($result3); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($result3); - } - else $error++; - + foreach($sqls as $sql){ + $resql = $db->query($sql); + if($resql){ + while($sqlobj = $db->fetch_object($resql)){ + $tab_sqlobj[] = $sqlobj; + $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); + } + $db->free($resql); + }else{ + $error++; + } + } // Sort array if (! $error) @@ -228,7 +208,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $num = count($tab_sqlobj); - //$num = $db->num_rows($result); $i = 0; while ($i < $num) { @@ -236,7 +215,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $ref = ''; $refcomp = ''; - //$obj = $db->fetch_object($result); $obj = array_shift($tab_sqlobj); if ($obj->family == 'invoice_supplier') @@ -284,6 +262,14 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done } + $parameters = array('obj' => $obj); + $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook)){ + $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; + $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; + $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; + } + $total_ttc = $obj->total_ttc; if ($paiement) $total_ttc = $obj->total_ttc - $paiement; $solde += $total_ttc; @@ -291,8 +277,6 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // We discard lines with a remainder to pay to 0 if (price2num($total_ttc) != 0) { - - // Show line print '
    '; print ''; print ''; print ''; print ''; print "
    '.$langs->trans("Categories").''; if (! empty($conf->use_javascript_ajax)) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 8fd1f1b0030..f968f9800e9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -251,6 +252,19 @@ if ($action == 'add') } } $object->fk_project = isset($_POST["projectid"])?$_POST["projectid"]:0; + + $taskid = GETPOST('taskid','int'); + if(!empty($taskid)){ + + $taskProject = new Task($db); + if($taskProject->fetch($taskid)>0){ + $object->fk_project = $taskProject->fk_project; + } + + $object->fk_element = $taskid; + $object->elementtype = 'task'; + } + $object->datep = $datep; $object->datef = $datef; $object->percentage = $percentage; @@ -876,11 +890,38 @@ if ($action == 'create') { // Projet associe $langs->load("projects"); + + $projectid = GETPOST('projectid', 'int'); - print '
    '.$langs->trans("Project").''; + print '
    '.$langs->trans("Project").''; - $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), GETPOST("projectid")?GETPOST("projectid"):'', 'projectid', 0, 0, 1, 1); + $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); + print '   '.$langs->trans("AddProject").''; + $urloption='?action=create'; + $url = dol_buildpath('comm/action/card.php',2).$urloption; + + // update task list + print "\n".''."\n"; + + print '
    '.$langs->trans("Task").''; + + $projectsListId=false; + if(!empty($projectid)){ $projectsListId=$projectid; } + $tid=GETPOST("projecttaskid")?GETPOST("projecttaskid"):''; + $formproject->selectTasks((! empty($societe->id)?$societe->id:-1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500',$projectsListId); print '
    '.$langs->trans("LinkedObject").''.dolGetElementUrl($object->fk_element,$object->elementtype,1); - print ''; - print ''; - print ''; + + $urloption='?action=create'; // we use create not edit for more flexibility + $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; + + // update task list + print "\n".''."\n"; + + $formproject->selectTasks((! empty($societe->id)?$societe->id:-1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500',$object->fk_project); + print ''; + + print ''; + print dolGetElementUrl($object->fk_element,$object->elementtype,1); + print ''; + print ''; + print '
    '; - print ''; + print ''; print ''; - print ''; + print ''; print '  
    '; - print img_object($langs->trans("ShowEMail"),"email").' '.stripslashes($obj->rowid).''; + print $email->getNomUrl(1); + print ''.$obj->titre.''; print dol_print_date($db->jdate($obj->datec),'day'); print ''.dol_print_date($db->jdate($obj->date_envoi),'day').''; if ($filteremail) @@ -210,7 +265,9 @@ if ($result) print $email->LibStatut($obj->statut,5); } print '
    '; @@ -315,15 +299,22 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) dol_print_error($db); } - // Solde actuel + // Other lines + $parameters = array('solde' => $solde); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook)){ + print $hookmanager->resPrint; + $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; + } + // solde print '
    '.$langs->trans("FutureBalance").' ('.$object->currency_code.')'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).'
    "; - print ""; + print ""; } else { diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php new file mode 100644 index 00000000000..2a4af918234 --- /dev/null +++ b/htdocs/compta/compta-files.php @@ -0,0 +1,310 @@ + + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2017 Pierre-Henry Favre + * + * 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/compta/recap-compta.php + * \ingroup compta + * \brief Page de fiche recap customer + */ +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +restrictedArea($user,'banque'); +$langs->load("companies"); +if (! empty($conf->facture->enabled)) $langs->load("bills"); +$date_start =GETPOST('date_start','alpha'); +$date_startDay= GETPOST('date_startday','int'); +$date_startMonth= GETPOST('date_startmonth','int'); +$date_startYear= GETPOST('date_startyear','int'); +$date_start=($date_startDay)?dol_mktime(0,0,0,$date_startMonth,$date_startDay,$date_startYear):strtotime($date_start); +$date_stop =GETPOST('date_stop','alpha'); +$date_stopDay= GETPOST('date_stopday','int'); +$date_stopMonth= GETPOST('date_stopmonth','int'); +$date_stopYear= GETPOST('date_stopyear','int'); +//FIXME doldate +$date_stop=($date_stopDay)?dol_mktime(0,0,0,$date_stopMonth,$date_stopDay,$date_stopYear):strtotime($date_stop); +$action =GETPOST('action','alpha'); +// Security check +//if ($user->societe_id) $id=$user->societe_id; +//$result = restrictedArea($user, 'societe', $id, '&societe'); +//$object = new Societe($db); +//if ($id > 0) $object->fetch($id); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('comptafilescard','globalcard')); +// 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; +if (! $sortfield) $sortfield="f.datef,f.rowid"; // Set here default search field +if (! $sortorder) $sortorder="DESC"; +$arrayfields=array( + 'date'=>array('label'=>"Date", 'checked'=>1), + //... +); +/* + * Actions + */ +//$parameters = array('socid' => $id); +//$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks +//if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +/* + * Fetch the lines/files from db / + */ +$filesarray=array(); +$result=false; +if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ + $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; + $sql="SELECT rowid as id, facnumber as ref,paye as paid,total_ttc,fk_soc,datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; + $sql.=" WHERE datef between ".$wheretail; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id,ref, paye as paid, total_ttc, fk_soc,datef as date, 'InvoiceSupplier' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql.=" WHERE datef between ".$wheretail; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id,ref,paid,total_ttc,fk_user_author as fk_soc,date_fin as date,'Expense' as item FROM ".MAIN_DB_PREFIX."expensereport"; + $sql.=" WHERE date_fin between ".$wheretail; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id,ref,paid,amount as total_ttc,CONCAT(firstname,' ',lastname) as fk_soc,datedon as date,'Donation' as item FROM ".MAIN_DB_PREFIX."don"; + $sql.=" WHERE datedon between ".$wheretail; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id,label as ref,1 as paid,amount as total_ttc,fk_user as fk_soc,datep as date,'Salary' as item FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql.=" WHERE datep between ".$wheretail; + $sql.=" UNION ALL"; + $sql.=" SELECT rowid as id,num_paiement as ref,1 as paid,amount as total_ttc,fk_charge as fk_soc,datep as date,'Charge' as item FROM ".MAIN_DB_PREFIX."paiementcharge"; + $sql.=" WHERE datep between ".$wheretail; + $resd = $db->query($sql); + $files=array(); + $link=''; + + if ($resd) + { + $numd = $db->num_rows($resd); + + $upload_dir =''; + $i=0; + while($i<$numd) + { + + + $objd = $db->fetch_object($resd); + + switch($objd->item){ + case "Invoice": + $subdir=dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->facture->dir_output.'/'.$subdir; + $link="../../document.php?modulepart=facture&file=".str_replace('/','%2F',$subdir).'%2F'; + break; + case "InvoiceSupplier": + $subdir=get_exdir($objd->id,2,0,0,$objd,'invoice_supplier').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; + $link="../../document.php?modulepart=facture_fournisseur&file=".str_replace('/','%2F',$subdir).'%2F'; + break; + case "Expense": + $subdir=dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; + $link="../../document.php?modulepart=expensereport&file=".str_replace('/','%2F',$subdir).'%2F'; + break; + case "Salary": + $subdir=dol_sanitizeFileName($objd->id); + $upload_dir = $conf->salaries->dir_output.'/'.$subdir; + $link="../../document.php?modulepart=salaries&file=".str_replace('/','%2F',$subdir).'%2F'; + break; + case "Donation": + $subdir=get_exdir(null,2,0,1,$objd,'donation'). '/'. dol_sanitizeFileName($objd->id); + $upload_dir = $conf->don->dir_output . '/' . $subdir; + $link="../../document.php?modulepart=don&file=".str_replace('/','%2F',$subdir).'%2F'; + break; + case "Charge": + $subdir=dol_sanitizeFileName($objd->id); + $upload_dir = $conf->tax->dir_output . '/' . $subdir; + $link="../../document.php?modulepart=tax&file=".str_replace('/','%2F',$subdir).'%2F'; + break; + default: + break; + } + + if(!empty($upload_dir)){ + $result=true; + $files=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$','',SORT_ASC,1); + foreach ($files as $key => $file){ + $file['date']=$db->idate($objd->date); + $file['paid']=$objd->paid; + $file['amount']=$objd->total_ttc; + $file['ref']=$objd->ref; + $file['fk']=$objd->fk_soc; + $file['item']=$objd->item; + $file['link']=$link.$file['name']; + $out.= '
    '.$file['name'].''; + $filesarray[]=$file; + } + if(count($files)<1){ + $nofile['date']=$db->idate($objd->date); + $nofile['paid']=$objd->paid; + $nofile['amount']=$objd->total_ttc; + $nofile['ref']=$objd->ref; + $nofile['fk']=$objd->fk_soc; + $nofile['item']=$objd->item; + $filesarray[]=$nofile; + } + } + $i++; + } + } + $db->free($resd); + +} +/* + * cleanup of old ZIP + */ +//FIXME +/* +*ZIP creation +*/ +if($result & $action=="dl"){ + unset($zip); + $log='date,type,ref,total,paid,filename,item_id'."\n"; + $zipname = ($date_start)."-".($date_stop).'_export.zip'; + $zip = new ZipArchive; + $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); + if ($res){ + foreach ($filesarray as $key=> $file) { + if(file_exists($file["fullname"])) $zip->addFile($file["fullname"],$file["name"]);// + $log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; + } + $zip->addFromString('log.csv', $log); + $zip->close(); + ///Then download the zipped file. + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.$zipname); + header('Content-Length: ' . filesize($zipname)); + readfile($zipname); + unlink($zipname); + exit(); + } +} +// None +/* + * View + */ +$form = new Form($db); +$userstatic=new User($db); +$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List"); +//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Symmary"); +$help_url='EN:Module_Accounting|FR:Module_Compatibilite'; //FIXME +llxHeader('',$title,$help_url); +print ''."\n\t\t"; +if (!empty($date_start) && !empty($date_stop))echo dol_print_date($date_start)." - ".dol_print_date($date_stop); +print ''; +print ''; +//if (! empty($arrayfields['f.datef']['checked'])) +print_liste_field_titre($arrayfields['date']['label'],$_SERVER["PHP_SELF"],"date","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +if ($result) +{ + $TData = dol_sort_array($filesarray, 'date', 'ASC'); + if(empty($TData)) { + print ''; + } else { + // Sort array by date ASC to calucalte balance + + $totalDebit = 0; + $totalCredit = 0; + // Balance calculation + $balance = 0; + foreach($TData as &$data1) { + if($data1['item']!='Invoice'&& $data1['item']!='Donation' ){ + $data1['amount']=-$data1['amount']; + } + if ($data1['amount']>0){ + }else{ + } + $balance += $data1['amount']; + $data1['balance'] = $balance; + } + // Display array + foreach($TData as $data) { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print ''; + print "\n"; + print ''; + print ''; + print '\n"; + print ''; + print '\n"; + $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; + print '\n"; + $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); + // Balance + print '\n"; + print "\n"; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + + } +print "
    '.$langs->trans("Type").''.$langs->trans("Ref").''.$langs->trans("File").''.$langs->trans("Paid").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").'
    '.$langs->trans("NoItem").'
    "; + print dol_print_date($data['date'],'day'); + print "'.$data['item'].''.$data['ref'].' ".$data['name']."'.$data['paid'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['balance'])."
     '.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).'
    "; +print '
    '."\n\t\t\t"; + +print ''; +print ''; + +//print ''; +//print ''; +//print ''; + +//print ''; +//print ''; +//print ''; + + +print '
    '."\n\t\t\n\t\t
    \n\t\t\t"; + + + +llxFooter(); +$db->close(); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a40ad636976..f1419f83e45 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3644,7 +3644,7 @@ else if ($id > 0 || ! empty($ref)) $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherBills").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherBills").')'; // Project if (! empty($conf->projet->enabled)) { @@ -4463,6 +4463,7 @@ else if ($id > 0 || ! empty($ref)) print '
      
     
    '; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; + if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1); + print $staffArray[$obj->staff_code]; + print '
    jabberid).'">
    jabberid).'">
    skype).'">
    skype).'">
    twitter).'">
    facebook).'">
    skype).'">
    skype).'">
    twitter).'">
    facebook).'">
    '.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$object->thirdparty->getAvailableDiscounts(); + if ($object->thirdparty->remise_percent) { + print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent); + } else { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); @@ -239,9 +241,7 @@ if ($id > 0 || ! empty($ref)) // Contacts lines include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; - } - else - { + } else { print "ErrorRecordNotFound"; } } diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 302ad161241..d2d34cd523a 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -28,8 +28,7 @@ // Filename to print must be provided into 'file' parameter // Print file -if ($action == 'print_file' && $user->rights->printing->read) -{ +if ($action == 'print_file' && $user->rights->printing->read) { $langs->load("printing"); require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php'; $objectprint = new PrintingDriver($db); @@ -55,7 +54,7 @@ if ($action == 'print_file' && $user->rights->printing->read) $subdir = 'commande'; } try { - $ret = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir); + $ret = $printer->printFile(GETPOST('file', 'alpha'), $module, $subdir); if ($ret > 0) { //print '
    '.print_r($printer->errors, true).'
    '; setEventMessages($printer->error, $printer->errors, 'errors'); diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 54d265bf6af..dd64a07b8d9 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -86,7 +86,7 @@ class box_factures_imp extends ModeleBoxes if ($user->rights->facture->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; $sql.= " s.code_client,"; $sql.= " s.logo,"; $sql.= " f.facnumber, f.date_lim_reglement as datelimite,"; @@ -134,9 +134,11 @@ class box_factures_imp extends ModeleBoxes $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); + $societestatic->id = $objp->socid; $societestatic->name = $objp->name; $societestatic->client = 1; + $societestatic->email = $objp->email; $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 45998a78869..d1a46e4d0b9 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -59,7 +59,11 @@ class CMailFile var $eol; var $eol2; - var $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; var $smtps; // Contains SMTPs object (if this method is used) var $phpmailer; // Contains PHPMailer object (if this method is used) @@ -1027,7 +1031,7 @@ class CMailFile $mimedone=0; $out = ""; - if ($filename_list) + if (is_array($filename_list)) { $filename_list_size=count($filename_list); for($i=0;$i < $filename_list_size;$i++) @@ -1199,7 +1203,7 @@ class CMailFile /** * Attach an image to email (mode = 'mail') * - * @param array $images_list Tableau + * @param array $images_list Array of array image * @return string Chaine images encodees */ function write_images($images_list) @@ -1207,7 +1211,7 @@ class CMailFile // phpcs:enable $out = ''; - if ($images_list) + if (is_array($images_list)) { foreach ($images_list as $img) { diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index c2512af70ef..b6c334f7e1c 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -34,15 +34,18 @@ */ class CSMSFile { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - var $addr_from; - var $addr_to; - var $deferred; - var $priority; - var $class; - var $message; - var $nostop; + public $addr_from; + public $addr_to; + public $deferred; + public $priority; + public $class; + public $message; + public $nostop; /** diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index d18501d54d9..c67e3f5f59d 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -40,7 +40,10 @@ class AntiVir */ public $errors = array(); - var $output; + /** + * @var string Used to return message + */ + public $output; /** * @var DoliDB Database handler. diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index a4665701661..cf830048cc0 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -43,15 +43,15 @@ class Canvas */ public $errors = array(); - var $actiontype; + public $actiontype; - var $dirmodule; // Module directory - var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas (ex: company, individual, product, service, ...) - var $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance /** diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 2f9a8636c8b..f07916a7511 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -76,7 +76,6 @@ class Ccountry // extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a818bfe7a2f..3792aaf9327 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -33,7 +33,11 @@ */ abstract class CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; + protected $db; @@ -491,11 +495,11 @@ abstract class CommonDocGenerator /** * Define array with couple substitution key => substitution value * - * @param array $line Array of lines + * @param Object $line Object line * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_lines($line,$outputlangs) + function get_substitutionarray_lines($line, $outputlangs) { // phpcs:enable global $conf; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index e9be4b1f9da..9b1cb8776c3 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -431,11 +431,11 @@ abstract class CommonInvoice extends CommonObject { global $langs; if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); - if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); - if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); - if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. - if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); + elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); + elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); + elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. + elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } @@ -475,10 +475,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); - return $langs->trans('Bill'.$prefix.'StatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); + else return $langs->trans('Bill'.$prefix.'StatusStarted'); } else { @@ -493,10 +493,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); - return $langs->trans('Bill'.$prefix.'StatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); + else return $langs->trans('Bill'.$prefix.'StatusStarted'); } else { @@ -511,10 +511,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); - return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); } else { @@ -529,10 +529,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); - if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); - return img_picto($langs->trans('BillStatusStarted'),'statut3'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); + else return img_picto($langs->trans('BillStatusStarted'),'statut3'); } else { @@ -547,10 +547,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); - return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); } else { @@ -566,14 +566,14 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); - if ($alreadypaid <= 0) + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); + elseif ($alreadypaid <= 0) { if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'),'statut1'); return ''.$langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); } - return ''.$langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('BillStatusStarted'),'statut3'); + else return ''.$langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('BillStatusStarted'),'statut3'); } else { @@ -598,7 +598,9 @@ abstract class CommonInvoice extends CommonObject if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; - $cdr_nbjour=0; $cdr_type=0; $cdr_decalage=0; + $cdr_nbjour=0; + $cdr_type=0; + $cdr_decalage=0; $sqltemp = 'SELECT c.type_cdr,c.nbjour,c.decalage'; $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7991bbb9ae9..8f7366541e3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1164,8 +1164,8 @@ abstract class CommonObject $sql.= " ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE ec.element_id = ".$id; $sql.= " AND ec.fk_socpeople = c.rowid"; - if ($source == 'internal') $sql.= " AND c.entity IN (0,".$conf->entity.")"; - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('socpeople').")"; + if ($source == 'internal') $sql.= " AND c.entity IN (".getEntity('user').")"; + if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")"; $sql.= " AND ec.fk_c_type_contact = tc.rowid"; $sql.= " AND tc.element = '".$element."'"; $sql.= " AND tc.source = '".$source."'"; @@ -2899,6 +2899,7 @@ abstract class CommonObject // Special case if ($origin == 'order') $origin='commande'; if ($origin == 'invoice') $origin='facture'; + if ($origin == 'invoice_template') $origin='facturerec'; $this->db->begin(); @@ -3824,6 +3825,7 @@ abstract class CommonObject print '
     
    '; print ''; print '
    '; + print ''; print ' '.$langs->trans("ECMSections"); print '
    '; + // Show the link to "Root" + if ($showroot) + { + print '
    '; + + // Show filemanager tree (will be filled by call of ajax /ecm/tpl/enablefiletreeajax.tpl.php that execute ajaxdirtree.php) print '
    '; if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile'); @@ -170,7 +177,7 @@ if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg } else { - print '
    '; + print '
    '; $_POST['modulepart'] = $module; $_POST['openeddir'] = GETPOST('openeddir'); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index d53012191af..f3367d3e90f 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -78,7 +78,7 @@ $(document).ready(function () { -
    - + - + + +
    @@ -207,7 +213,9 @@ if ($forgetpasslink || $helpcenterlink) echo '
    '; echo '
    '; if ($forgetpasslink) { - echo ''; + $url=DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam; + if (! empty($conf->global->MAIN_PASSWORD_FORGOTLINK)) $url=$conf->global->MAIN_PASSWORD_FORGOTLINK; + echo ''; echo $langs->trans('PasswordForgotten'); echo ''; } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f429f7216c0..23640216cd9 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -160,6 +160,7 @@ if ($nolinesbefore) { ?> global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay=2; ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 848ac6dbf21..776506bdaee 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -66,7 +66,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; ?> - > + > global->MAIN_VIEW_LINE_NUMBER)) { ?> diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 62a441643e7..0e1942c1c64 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -66,7 +66,7 @@ $(document).ready(function () { - diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index a8de26e713b..772e9b39a51 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -37,7 +37,13 @@ class InterfaceLogevents extends DolibarrTriggers public $picto = 'technic'; public $family = 'core'; + public $description = "Triggers of this module allows to add security event records inside Dolibarr."; + + /** + * Version of the trigger + * @var string + */ public $version = self::VERSION_DOLIBARR; /** diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index a719ef0b4fc..90806746da8 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -39,6 +39,11 @@ class InterfaceWorkflowManager extends DolibarrTriggers public $family = 'core'; public $description = "Triggers of this module allows to manage workflows"; + + /** + * Version of the trigger + * @var string + */ public $version = self::VERSION_DOLIBARR; /** diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 679801692d2..938b63d90f3 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -36,6 +36,11 @@ class InterfaceActionsAuto extends DolibarrTriggers { public $family = 'agenda'; public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; + + /** + * Version of the trigger + * @var string + */ public $version = self::VERSION_DOLIBARR; /** @@ -246,8 +251,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_UNVALIDATE') { - // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills"));; + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); @@ -533,7 +538,7 @@ class InterfaceActionsAuto extends DolibarrTriggers elseif ($action == 'BILL_SUPPLIER_VALIDATE') { // Load translation files required by the page - $langs->loadLangs(array("agenda","other","bills"));; + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -752,7 +757,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } // TODO Merge all previous cases into this generic one - else { + else + { // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) // Load translation files required by the page $langs->loadLangs(array("agenda","other")); diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 82e6b9e56eb..f2c19394df9 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -32,6 +32,11 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers { public $family = 'system'; public $description = "Triggers of this module add action for BlockedLog module."; + + /** + * Version of the trigger + * @var string + */ public $version = self::VERSION_DOLIBARR; /** diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 376ed47c486..7d528b55c30 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -33,6 +33,11 @@ class InterfaceLdapsynchro extends DolibarrTriggers { public $family = 'ldap'; public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database."; + + /** + * Version of the trigger + * @var string + */ public $version = self::VERSION_DOLIBARR; /** diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index e551086f9e8..0197e6bf280 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -31,6 +31,11 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers { public $family = 'mailmanspip'; public $description = "Triggers of this module allows to synchronize Mailman an Spip."; + + /** + * Version of the trigger + * @var string + */ public $version = self::VERSION_DOLIBARR; /** diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 0daf141a208..26b36964676 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -32,6 +32,11 @@ class InterfaceNotification extends DolibarrTriggers { public $family = 'notification'; public $description = "Triggers of this module send email notifications according to Notification module setup."; + + /** + * Version of the trigger + * @var string + */ public $version = self::VERSION_DOLIBARR; /** diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 246826106f7..c1cf1bfd936 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -114,7 +114,7 @@ class InterfaceStripe */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - // Put here code you want to execute when a Dolibarr business events occurs. + // Put here code you want to execute when a Dolibarr business event occurs. // Data and type of action are stored into $object and $action global $langs, $db, $conf; diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 46b1f955177..3ed3a92cb50 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2018 Laurent Destailleur * * 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 @@ -19,10 +19,11 @@ /** * \file htdocs/core/website.inc.php * \brief Common file loaded used by all website pages (after master.inc.php) - * The global variable $website must be defined. + * The global variable $websitekey must be defined. */ - include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; $website=new Website($db); $website->fetch(0,$websitekey); + +include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 65cd68e8431..2d4b74a3b5a 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -680,13 +680,14 @@ else print $langs->trans('CronDtNextLaunch'); print ' ('.$langs->trans('CronFrom').')'; print ""; - //print ''; if (! $object->status) print $langs->trans("Disabled"); elseif (!empty($object->datenextrun)) { print img_picto('','object_calendarday').' '.dol_print_date($object->datenextrun,'dayhoursec');} - else {print $langs->trans('CronNone');} - //print ''; - if ($object->maxnbrun && $object->nbrun >= $object->maxrun) print img_warning($langs->trans("Finished")); - if ($object->datenextrun && $object->datenextrun < $now) print img_warning($langs->trans("Late")); + else { print $langs->trans('CronNone'); } + if ($object->status == Cronjob::STATUS_ENABLED) + { + if ($object->maxrun && $object->nbrun >= $object->maxrun) print img_warning($langs->trans("MaxRunReached")); + elseif ($object->datenextrun && $object->datenextrun < $now) print img_warning($langs->trans("Late")); + } print ""; print ''; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 670ac6556b7..dc853e0da7d 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -92,7 +92,6 @@ class Cronjob extends CommonObject function __construct($db) { $this->db = $db; - return 1; } @@ -245,8 +244,8 @@ class Cronjob extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."cronjob"); - if (! $notrigger) - { + //if (! $notrigger) + //{ // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -256,7 +255,7 @@ class Cronjob extends CommonObject //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } + //} } // Commit or rollback @@ -431,7 +430,7 @@ class Cronjob extends CommonObject $sql.= " WHERE 1 = 1"; if ($processing >= 0) $sql.= " AND t.processing = ".(empty($processing)?'0':'1'); if ($status >= 0 && $status < 2) $sql.= " AND t.status = ".(empty($status)?'0':'1'); - if ($status == 2) $sql.= " AND t.status = 2"; + elseif ($status == 2) $sql.= " AND t.status = 2"; //Manage filter if (is_array($filter) && count($filter)>0) { foreach($filter as $key => $value) @@ -634,10 +633,8 @@ class Cronjob extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { + //if (! $error && ! $notrigger) + //{ // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -647,8 +644,7 @@ class Cronjob extends CommonObject //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + //} // Commit or rollback if ($error) @@ -764,11 +760,11 @@ class Cronjob extends CommonObject $error++; } - if (! $error) - { + //if (! $error) + //{ - } + //} unset($this->context['createfromclone']); @@ -1305,34 +1301,33 @@ class Cronjob extends CommonObject if ($mode == 0) { - $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 1) + elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 2) + elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); } - if ($mode == 3) + elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); } - if ($mode == 4) + elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); } - if ($mode == 5) + elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); } } } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index eb326673d25..1f810132223 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -242,6 +242,7 @@ $sql.= " t.status,"; $sql.= " t.fk_user_author,"; $sql.= " t.fk_user_mod,"; $sql.= " t.note,"; +$sql.= " t.maxrun,"; $sql.= " t.nbrun,"; $sql.= " t.libname,"; $sql.= " t.test"; @@ -252,12 +253,12 @@ if ($search_status == 2) $sql.= " AND t.status = 2"; //Manage filter if (is_array($filter) && count($filter)>0) { foreach($filter as $key => $value) { - $sql.= ' AND '.$key.' LIKE \'%'.$value.'%\''; + $sql.= ' AND '.$key.' LIKE \'%'.$db->escape($value).'%\''; } } $sqlwhere = array(); if (!empty($module_name)) { - $sqlwhere[]='(t.module_name='.$module_name.')'; + $sqlwhere[]='(t.module_name='.$db->escape($module_name).')'; } if (count($sqlwhere)>0) { $sql.= " WHERE ".implode(' AND ',$sqlwhere); @@ -519,9 +520,15 @@ if ($num > 0) print ''; print ''; - if(!empty($obj->datenextrun)) { + if (!empty($obj->datenextrun)) { + $datenextrun = $db->jdate($obj->datenextrun); if (empty($obj->status)) print ''; - print dol_print_date($db->jdate($obj->datenextrun),'dayhour'); + print dol_print_date($datenextrun,'dayhoursec'); + if ($obj->status == Cronjob::STATUS_ENABLED) + { + if ($obj->maxrun && $obj->nbrun >= $obj->maxrun) print img_warning($langs->trans("MaxRunReached")); + elseif ($datenextrun && $datenextrun < $now) print img_warning($langs->trans("Late")); + } if (empty($obj->status)) print ''; } print ''; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 279f8d980de..0723ecb659a 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -107,7 +107,7 @@ class Don extends CommonObject function LibStatut($statut,$mode=0) { // phpcs:enable - if (empty($this->labelstatut) || empty($this->labelstatushort)) + if (empty($this->labelstatut) || empty($this->labelstatutshort)) { global $langs; $langs->load("donations"); @@ -132,37 +132,37 @@ class Don extends CommonObject elseif ($mode == 2) { if ($statut == -1) return img_picto($this->labelstatut[$statut],'statut5').' '.$this->labelstatutshort[$statut]; - if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatutshort[$statut]; - if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatutshort[$statut]; - if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatutshort[$statut]; + elseif ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatutshort[$statut]; + elseif ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatutshort[$statut]; + elseif ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatutshort[$statut]; } elseif ($mode == 3) { if ($statut == -1) return img_picto($this->labelstatut[$statut],'statut5'); - if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0'); - if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1'); - if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6'); + elseif ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0'); + elseif ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1'); + elseif ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6'); } elseif ($mode == 4) { if ($statut == -1) return img_picto($this->labelstatut[$statut],'statut5').' '.$this->labelstatut[$statut]; - if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatut[$statut]; - if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; - if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; + elseif ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatut[$statut]; + elseif ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + elseif ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; } elseif ($mode == 5) { if ($statut == -1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut5'); - if ($statut == 0) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut0'); - if ($statut == 1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); - if ($statut == 2) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); + elseif ($statut == 0) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut0'); + elseif ($statut == 1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + elseif ($statut == 2) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } elseif ($mode == 6) { if ($statut == -1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut5'); - if ($statut == 0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut0'); - if ($statut == 1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); - if ($statut == 2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); + elseif ($statut == 0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut0'); + elseif ($statut == 1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + elseif ($statut == 2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } } diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index e4a7ef5c5d4..dde03cb461d 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -28,9 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->load('bills'); -$langs->load('banks'); -$langs->load('companies'); +// Load translation files required by the page +$langs->loadLangs(array("bills","banks","companies")); // Security check $id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int'); diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index 0a51e8cc73d..b7c20e33d2d 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -27,7 +27,7 @@ if (empty($conf) || ! is_object($conf)) ?> - + '."\n"; // We include full because we need the support of containerCssClass } - } + if (! defined('DISABLE_MULTISELECT')) // jQuery plugin "mutiselect" to select with checkboxes + { + print ''."\n"; + } + } if (! $disablejs && ! empty($conf->use_javascript_ajax)) { diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index 26e64785524..6ca9bfe2a1e 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -73,7 +73,7 @@ if (preg_match('/del_(.*)/', $action, $reg)) { } } - + /* * View */ @@ -87,73 +87,78 @@ if (GETPOST('withtab', 'alpha')) { $linkback = '' . $langs->trans("BackToModuleList") . ''; } +print ''; +print ''; +print ''; + print load_fiche_titre($langs->trans("ModuleSetup") . ' ' . $langs->trans('Modulebuilder'), $linkback); if (GETPOST('withtab', 'alpha')) { dol_fiche_head($head, 'modulebuilder', '', -1); } - print '' . $langs->trans("ModuleBuilderDesc") . "
    \n"; print '
    '; print ''; + print ''; print ''; print ''; print "\n"; -print ''; -print ''; -print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; } -print ''; - - print ''; -print ''; -print ''; - -print ''; -print ''; -print ''; - -print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print '
    ' . $langs->trans("Key") . '' . $langs->trans("Value") . '
    ' . $langs->trans("UseAboutPage") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); -} else { - if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; - } else { - print '' . img_picto($langs->trans("Enabled"), 'on') . ''; - } + +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) +{ + // What is use cas of this 2 options ? + + print '
    ' . $langs->trans("UseAboutPage") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); + } else { + if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } else { + print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + } + } + print '
    ' . $langs->trans("UseDocFolder") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MODULEBUILDER_USE_DOCFOLDER'); + } else { + if (empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)) { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } else { + print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + } + } + print '
    ' . $langs->trans("UseDocFolder") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MODULEBUILDER_USE_DOCFOLDER'); -} else { - if (empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)) { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; - } else { - print '' . img_picto($langs->trans("Enabled"), 'on') . ''; - } -} -print '
    ' . $langs->trans("UseSpecificReadme") . ''; -print ''; -print '
    '; -print ''; -print '
    ' . $langs->trans("UseSpecificReadme") . ''; +print ''; +print '
    '; +print '
    '; + if (GETPOST('withtab', 'alpha')) { dol_fiche_end(); } -print '

    '; +print '
    '; + +print ''; // End of page llxFooter(); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 2cc6468729c..6e0be4d0011 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -85,7 +85,7 @@ $head = mymoduleAdminPrepareHead(); dol_fiche_head($head, 'settings', '', -1, "mymodule@mymodule"); // Setup page goes here -echo $langs->trans("MyModuleSetupPage"); +echo $langs->trans("MyModuleSetupPage").'

    '; if ($action == 'edit') @@ -99,13 +99,10 @@ if ($action == 'edit') foreach($arrayofparameters as $key => $val) { - if (isset($val['enabled']) && empty($val['enabled'])) continue; - print ''; print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); print ''; } - print ''; print '
    '; @@ -117,21 +114,28 @@ if ($action == 'edit') } else { - print ''; - print ''; - - foreach($arrayofparameters as $key => $val) + if (! empty($arrayofparameters)) { - print ''; + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
    '; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; + print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); + print '' . $conf->global->$key . '
    '; + + print '
    '; + print ''.$langs->trans("Modify").''; + print '
    '; + } + else + { + print '
    '.$langs->trans("NothingToSetup"); } - - print ''; - - print '
    '; - print ''.$langs->trans("Modify").''; - print '
    '; } @@ -140,3 +144,4 @@ dol_fiche_end(); llxFooter(); $db->close(); + diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 45008aa76f3..7d85d804d25 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -32,10 +32,12 @@ class ActionsMyModule * @var DoliDB Database handler. */ public $db; + /** - * @var string Error + * @var string Error code (or message) */ public $error = ''; + /** * @var array Errors */ diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 2da97f5b800..c5355958833 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -202,7 +202,7 @@ class MyObject extends CommonObject */ public function createFromClone(User $user, $fromid) { - global $hookmanager, $langs; + global $langs, $hookmanager, $extrafields; $error = 0; dol_syslog(__METHOD__, LOG_DEBUG); @@ -222,6 +222,20 @@ class MyObject extends CommonObject $object->ref = "copy_of_".$object->ref; $object->title = $langs->trans("CopyOf")." ".$object->title; // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } // Create clone $object->context['createfromclone'] = 'createfromclone'; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 728270d6179..7805e8f05eb 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -200,10 +200,10 @@ class modMyModule extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true) + 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled') ); - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled'), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled') // ); diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index ab72aabaee0..549f0fd411a 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -20,15 +20,14 @@ */ /** - * \file dev/skeletons/skeleton_class.class.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) - * Put some comments here + * \file htdocs/multicurrency/class/multicurrency.class.php + * \ingroup multicurrency + * \brief This file is a CRUD class file (Create/Read/Update/Delete) for multicurrency */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php"; +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; /** * Class Currency diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 169aebde712..2e6789b3f89 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -111,7 +111,6 @@ class Opensurveysondage extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index b2300c7125a..529ad7e33ec 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -109,12 +109,12 @@ if ($action == 'setvalue' && $user->admin) $form = new Form($db); -llxHeader('',$langs->trans("PrintingSetup")); +llxHeader('', $langs->trans("PrintingSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("PrintingSetup"),$linkback,'title_setup'); -$head=printingadmin_prepare_head($mode); +$head = printingAdminPrepareHead($mode); if ($mode == 'setup' && $user->admin) { @@ -134,8 +134,7 @@ if ($mode == 'setup' && $user->admin) print "\n"; $submit_enabled=0; - if (! empty($driver)) - { + if (! empty($driver)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; $classname = 'printing_'.$driver; $langs->load($driver); @@ -304,7 +303,7 @@ if ($mode == 'test' && $user->admin) $langs->load($driver); $printer = new $classname($db); //print '
    '.print_r($printer, true).'
    '; - if (count($printer->getlist_available_printers())) { + if (count($printer->getlistAvailablePrinters())) { if ($printer->listAvailablePrinters()==0) { print $printer->resprint; } else { diff --git a/htdocs/printing/index.php b/htdocs/printing/index.php index 9abb4dbb3f2..a95e3517be6 100644 --- a/htdocs/printing/index.php +++ b/htdocs/printing/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2016 Laurent Destailleur +/* Copyright (C) 2014-2018 Frederic France + * Copyright (C) 2016 Laurent Destailleur * * 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 @@ -40,29 +40,26 @@ $langs->load("printing"); * View */ -llxHeader("",$langs->trans("Printing")); +llxHeader("", $langs->trans("Printing")); -print_barre_liste($langs->trans("Printing"), 0, $_SERVER["PHP_SELF"], '', '', '', ''.$langs->trans("Refresh").'', 0, 0, 'title_setup.png'); +print_barre_liste($langs->trans("Printing"), 0, $_SERVER["PHP_SELF"], '', '', '', '' . $langs->trans("Refresh") . '', 0, 0, 'title_setup.png'); print $langs->trans("DirectPrintingJobsDesc").'

    '; // List Jobs from printing modules $object = new PrintingDriver($db); $result = $object->listDrivers($db, 10); -foreach ($result as $driver) -{ +foreach ($result as $driver) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; $classname = 'printing_'.$driver; $langs->load($driver); $printer = new $classname($db); - if ($conf->global->{$printer->active}) - { - //$printer->list_jobs('commande'); - $result = $printer->list_jobs(); + if ($conf->global->{$printer->active}) { + //$printer->listJobs('commande'); + $result = $printer->listJobs(); print $printer->resprint; - if ($result > 0) - { + if ($result > 0) { setEventMessages($printer->error, $printer->errors, 'errors'); } } diff --git a/htdocs/printing/lib/printing.lib.php b/htdocs/printing/lib/printing.lib.php index 697e986cd56..53257891e25 100644 --- a/htdocs/printing/lib/printing.lib.php +++ b/htdocs/printing/lib/printing.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2015 Laurent Destailleur + * Copyright (C) 2018 Frédéric France * * 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 @@ -26,10 +27,10 @@ /** * Define head array for tabs of printing tools setup pages * - * @param string $mode Mode - * @return Array of head + * @param string $mode Mode + * @return array Array of head */ -function printingadmin_prepare_head($mode) +function printingAdminPrepareHead($mode) { global $langs, $conf; @@ -41,28 +42,26 @@ function printingadmin_prepare_head($mode) $head[$h][2] = 'config'; $h++; - if ($mode == 'setup') - { - $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup&driver=".GETPOST('driver','alpha'); - $head[$h][1] = $langs->trans("SetupDriver"); - $head[$h][2] = 'setup'; - $h++; + if ($mode == 'setup') { + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup&driver=".GETPOST('driver','alpha'); + $head[$h][1] = $langs->trans("SetupDriver"); + $head[$h][2] = 'setup'; + $h++; } - if ($mode == 'test') - { - $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test&driver=".GETPOST('driver','alpha'); - $head[$h][1] = $langs->trans("TargetedPrinter"); - $head[$h][2] = 'test'; - $h++; + if ($mode == 'test') { + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test&driver=".GETPOST('driver','alpha'); + $head[$h][1] = $langs->trans("TargetedPrinter"); + $head[$h][2] = 'test'; + $h++; } - /** TODO This feature seem to be not ready yet. - $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf"; - $head[$h][1] = $langs->trans("UserConf"); - $head[$h][2] = 'userconf'; - $h++; - */ + /** TODO This feature seem to be not ready yet. + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf"; + $head[$h][1] = $langs->trans("UserConf"); + $head[$h][2] = 'userconf'; + $h++; + */ //$object=new stdClass(); @@ -76,4 +75,3 @@ function printingadmin_prepare_head($mode) return $head; } - diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 22b5e4656a7..5356d212c38 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -52,8 +52,6 @@ class FormProduct function __construct($db) { $this->db = $db; - - return 1; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2b5b9c71ba6..12ddfb9e6d7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -354,8 +354,6 @@ class Product extends CommonObject */ function __construct($db) { - global $langs; - $this->db = $db; $this->canvas = ''; } @@ -3656,10 +3654,10 @@ class Product extends CommonObject $label.="
    ".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0,2); } } - if ($this->type == Product::TYPE_SERVICE) - { + //if ($this->type == Product::TYPE_SERVICE) + //{ // - } + //} if (! empty($conf->accounting->enabled) && $this->status) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -3840,37 +3838,37 @@ class Product extends CommonObject if ($mode == 0) { if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); + elseif ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); } - if ($mode == 1) + elseif ($mode == 1) { if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); + elseif ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); } - if ($mode == 2) + elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); - if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); + elseif ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); } - if ($mode == 3) + elseif ($mode == 3) { if ($status == 0) return img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')),'statut5', 'class="pictostatus"'); - if ($status == 1) return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); + elseif ($status == 1) return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); } - if ($mode == 4) + elseif ($mode == 4) { if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); - if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); + elseif ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); } - if ($mode == 5) + elseif ($mode == 5) { if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); + elseif ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); } - if ($mode == 6) + elseif ($mode == 6) { if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); + elseif ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); } return $langs->trans('Unknown'); } diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index fc36c64a3eb..f6a7df212eb 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -56,7 +56,6 @@ class Productbatch extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 0d1d7ae4484..7f9e5a0b383 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -75,9 +75,7 @@ class Productcustomerprice extends CommonObject */ function __construct($db) { - $this->db = $db; - return 1; } /** diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index e58e09c4bfd..3a7f3fb586d 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -62,7 +62,6 @@ class Propalmergepdfproduct extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/product/dynamic_price/class/price_expression.class.php b/htdocs/product/dynamic_price/class/price_expression.class.php index c7300be5d20..6b73b413522 100644 --- a/htdocs/product/dynamic_price/class/price_expression.class.php +++ b/htdocs/product/dynamic_price/class/price_expression.class.php @@ -65,7 +65,6 @@ class PriceExpression function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index ebdba3b5949..4cd900979ab 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -71,7 +71,6 @@ class PriceGlobalVariable function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 14ea4357a66..b06a249ccc6 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -78,7 +78,6 @@ class PriceGlobalVariableUpdater function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 750b675c92a..5b0bbb99a65 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -368,44 +368,44 @@ class Inventory extends CommonObject { $prefix=''; if ($status == 0) return $langs->trans('Draft'); - if ($status == 1) return $langs->trans('Enabled'); - if ($status == -1) return $langs->trans('Canceled'); + elseif ($status == 1) return $langs->trans('Enabled'); + elseif ($status == -1) return $langs->trans('Canceled'); } - if ($mode == 1) + elseif ($mode == 1) { if ($status == 0) return $langs->trans('Draft'); - if ($status == 1) return $langs->trans('Enabled'); - if ($status == -1) return $langs->trans('Canceled'); + elseif ($status == 1) return $langs->trans('Enabled'); + elseif ($status == -1) return $langs->trans('Canceled'); } - if ($mode == 2) + elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft'); - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); + elseif ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + elseif ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); } - if ($mode == 3) + elseif ($mode == 3) { if ($status == 0) return img_picto($langs->trans('Draft'),'statut0'); - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6'); + elseif ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); + elseif ($status == -1) return img_picto($langs->trans('Canceled'),'statut6'); } - if ($mode == 4) + elseif ($mode == 4) { if ($status == 0) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft'); - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); + elseif ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + elseif ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); } - if ($mode == 5) + elseif ($mode == 5) { if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); + elseif ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + elseif ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); } - if ($mode == 6) + elseif ($mode == 6) { if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); + elseif ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + elseif ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); } } diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index e0c15d03520..1ab24b553d8 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2018 Frédéric France * * 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 @@ -126,7 +126,7 @@ class ProductStockEntrepot extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - if (!$notrigger) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -134,7 +134,7 @@ class ProductStockEntrepot extends CommonObject //$result=$this->call_trigger('MYOBJECT_CREATE',$user); //if ($result < 0) $error++; //// End call triggers - } + //} } // Commit or rollback @@ -340,7 +340,7 @@ class ProductStockEntrepot extends CommonObject dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); } - if (!$error && !$notrigger) { + //if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -348,7 +348,7 @@ class ProductStockEntrepot extends CommonObject //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} //// End call triggers - } + //} // Commit or rollback if ($error) { @@ -378,8 +378,7 @@ class ProductStockEntrepot extends CommonObject $this->db->begin(); - if (!$error) { - if (!$notrigger) { + //if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -387,8 +386,7 @@ class ProductStockEntrepot extends CommonObject //$result=$this->call_trigger('MYOBJECT_DELETE',$user); //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} //// End call triggers - } - } + //} if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; @@ -526,34 +524,33 @@ class ProductStockEntrepot extends CommonObject if ($mode == 0) { - $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 1) + elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 2) + elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 3) + elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); } - if ($mode == 4) + elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 5) + elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index c3351a5efff..623838f8149 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -118,6 +118,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_project_ref = ''; $search_thirdparty = ''; $search_declared_progress = ''; + + // We redefine $usertoprocess + $usertoprocess=$user; } if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) { @@ -345,7 +348,7 @@ if ($morewherefilter) // Get all task without any filter, so we can show total o } $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); -//var_dump($tasksarray); +//var_dump($usertoprocess); //var_dump($projectsrole); //var_dump($taskrole); @@ -502,7 +505,7 @@ print ''.$langs->trans("TimeSpent").($user print ''.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to -$restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); +$restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); // Get if user is available or not for each day $isavailable=array(); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index fdf7b9ea187..214879c7f92 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -129,6 +129,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_project_ref = ''; $search_thirdparty = ''; $search_declared_progress = ''; + + // We redefine $usertoprocess + $usertoprocess=$user; } if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) { @@ -594,8 +597,7 @@ if ($conf->use_javascript_ajax) // By default, we can edit only tasks we are assigned to -$restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); - +$restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index 84633944250..4164c1427b6 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -36,8 +36,6 @@ class TaskStats extends Stats */ function __construct($db) { - global $conf, $user; - $this->db = $db; require_once 'task.class.php'; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 83ebdc47507..3303d63ef81 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -712,6 +712,9 @@ foreach ($listofreferent as $key => $value) $testnew=$value['testnew']; $project_field=$value['project_field']; + $exclude_select_element = array('payment_various'); + if (!empty($value['exclude_select_element'])) $exclude_select_element[] = $value['exclude_select_element']; + if ($qualified) { // If we want the project task array to have details of users @@ -731,7 +734,7 @@ foreach ($listofreferent as $key => $value) if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; } - if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, array('payment_various'))) + if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename,$exclude_select_element)) { $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300',-2,!empty($project_field)?$project_field:'fk_projet'); if (! $selectList || ($selectList<0)) diff --git a/htdocs/public/donations/donateurs_code.php b/htdocs/public/donations/donateurs_code.php index 3705c9945bc..9f03f9e293e 100644 --- a/htdocs/public/donations/donateurs_code.php +++ b/htdocs/public/donations/donateurs_code.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2002 Rodolphe Quiedeville + * Copyright (C) 2018 Frédéric France * * 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 @@ -48,7 +49,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT .'/don/class/don.class.php'; // Security check -if (empty($conf->don->enabled)) accessforbidden('',0,0,1); +if (empty($conf->don->enabled)) accessforbidden('', 0, 0, 1); $langs->load("donations"); @@ -71,13 +72,13 @@ if ($resql) if ($num) { - print ""; + print "
    "; - print ''; + print ''; print ""; print ""; - print ""; - print "\n"; + print ""; + print "\n"; while ($i < $num) { diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 4d3a4a55c74..1c04a5633ec 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -61,7 +61,6 @@ class Dolresource extends CommonObject function __construct($db) { $this->db = $db; - return 1; } /** diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index b95ba78e2be..f541a7728cb 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -55,8 +55,6 @@ class FormResource function __construct($db) { $this->db = $db; - - return 1; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 427995254fc..ee4d05231ee 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -145,7 +145,7 @@ if (empty($reshook)) $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; $listofproperties=array( - 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', + 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', @@ -405,6 +405,8 @@ if (empty($reshook)) $object->country_id = GETPOST('country_id', 'int'); $object->state_id = GETPOST('state_id', 'int'); $object->skype = GETPOST('skype', 'alpha'); + $object->twitter = GETPOST('twitter', 'alpha'); + $object->facebook = GETPOST('facebook', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax','alpha'); $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); @@ -959,6 +961,8 @@ else $object->town = GETPOST('town', 'alpha'); $object->state_id = GETPOST('state_id', 'int'); $object->skype = GETPOST('skype', 'alpha'); + $object->twitter = GETPOST('twitter', 'alpha'); + $object->facebook = GETPOST('facebook', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); @@ -1240,17 +1244,32 @@ else print ''; } - // Email web + // Email / Web print ''; print ''; print ''; print ''; - // Skype - if (! empty($conf->skype->enabled)) + if (! empty($conf->socialnetworks->enabled)) { - print ''; - print ''; + // Skype + if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + { + print ''; + print ''; + } + // Twitter + if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + { + print ''; + print ''; + } + // Facebook + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print ''; + } } // Phone / Fax @@ -1377,16 +1396,14 @@ else print ''; } - if ($user->rights->societe->client->voir) - { - // Assign a Name - print ''; - print ''; - print ''; - } + // Assign a sale representative + print ''; + print ''; + print ''; // Incoterms if (!empty($conf->incoterm->enabled)) @@ -1538,6 +1555,8 @@ else $object->country_id = GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id; $object->state_id = GETPOST('state_id', 'int'); $object->skype = GETPOST('skype', 'alpha'); + $object->twitter = GETPOST('twitter', 'alpha'); + $object->facebook = GETPOST('facebook', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); @@ -1819,12 +1838,27 @@ else print ''; print ''; - // Skype - if (! empty($conf->skype->enabled)) - { - print ''; - print ''; - } + if (! empty($conf->socialnetworks->enabled)) + { + // Skype + if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + { + print ''; + print ''; + } + // Twitter + if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + { + print ''; + print ''; + } + // Facebook + if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + { + print ''; + print ''; + } + } // Phone / Fax print ''; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 07bc59f4757..3e514adf73a 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Pierre Chéné * * 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 @@ -1059,7 +1060,7 @@ class Thirdparties extends DolibarrApi } - $fields = ['socid', 'default_rib', 'frstrecur', '1000110000001', 'datec', 'datem', 'label', 'bank', 'bic', 'iban', 'id']; + $fields = ['socid', 'default_rib', 'frstrecur', '1000110000001', 'datec', 'datem', 'label', 'bank', 'bic', 'iban', 'id', 'rum']; $returnAccounts = []; @@ -1172,6 +1173,115 @@ class Thirdparties extends DolibarrApi } /** + * Generate a Document from a bank account record (like SEPA mandate) + * + * @param int $id thirdparty id + * @param int $companybankid companybankid + * @param string $model model of document to generate + * @return void + * + * @url GET {id}/generateBankAccountDocument/{companybankid}/{model} + */ + public function generateBankAccountDocument($id, $companybankid = null, $model = 'sepamandate') + { + global $conf; + + $this->langs->load("database"); + $this->langs->load("main"); + $this->langs->load("dict"); + $this->langs->load("agenda"); + $this->langs->load("margins"); + $this->langs->load("resource"); + $this->langs->load("commercial"); + $this->langs->load("ecm"); + $this->langs->load("products"); + $this->langs->load("companies"); + $this->langs->load("banks"); + $this->langs->load("bills"); + $this->langs->load("withdrawals"); + + $this->company->fetch($id); + + $action = 'builddoc'; + if(! DolibarrApiAccess::$user->rights->societe->creer) + throw new RestException(401); + + $this->company->setDocModel(DolibarrApiAccess::$user, $model); + + $this->company->fk_bank = $this->company->fk_account; + + $outputlangs = $this->langs; + $newlang=''; + + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty + if (! empty($newlang)) { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + // To be sure vars is defined + $hidedetails = $hidedesc = $hideref = 0; + $moreparams=null; + if (empty($hidedetails)) $hidedetails=0; + if (empty($hidedesc)) $hidedesc=0; + if (empty($hideref)) $hideref=0; + if (empty($moreparams)) $moreparams=null; + + + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql.= " WHERE fk_soc = ".$id." "; + if ($companybankid) $sql.= " AND id = ".$companybankid.""; + + $i=0; + $accounts=array(); + + $result = $this->db->query($sql); + if ($result) + { + if ($result->num_rows == 0) { + throw new RestException(404, 'Bank account not found'); + } + + $num = $this->db->num_rows($result); + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + + $account = new CompanyBankAccount($this->db); + if ($account->fetch($obj->rowid)) { + $accounts[] = $account; + } + $i++; + } + } + else + { + throw new RestException(404, 'Bank account not found'); + } + + $moreparams = array( + 'use_companybankid'=>$accounts[0]->id, + 'force_dir_output'=>$this->conf->societe->multidir_output[$this->company->entity].'/'.dol_sanitizeFileName($this->company->id) + ); + + $result = 0; + + $result = $this->company->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + + if ($result > 0) + { + return array("success" => $result); + } + else + { + throw new RestException(500); + } + } + + /** * Get a specific gateway attached to a thirdparty (by specifying the site key) * * @param int $id ID of thirdparty diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 53dc04218fa..7ee22384b39 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -79,9 +79,9 @@ class Societe extends CommonObject */ public $fields=array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), @@ -107,6 +107,11 @@ class Societe extends CommonObject */ public $nom; + /** + * @var string name + */ + public $name; + /** * Alias names (commercial, trademark or alias names) * @var string @@ -181,6 +186,16 @@ class Societe extends CommonObject * @var string */ public $skype; + /** + * Twitter username + * @var string + */ + public $twitter; + /** + * Facebook username + * @var string + */ + public $facebook; /** * Webpage * @var string @@ -529,7 +544,7 @@ class Societe extends CommonObject $this->add_commercial($user, $this->commercial_id); } // si un commercial cree un client il lui est affecte automatiquement - else if (empty($user->rights->societe->client->voir)) + elseif (empty($user->rights->societe->client->voir)) { $this->add_commercial($user, $user->id); } @@ -652,15 +667,15 @@ class Societe extends CommonObject { $this->errors[] = 'ErrorBadCustomerCodeSyntax'; } - if ($rescode == -2) + elseif ($rescode == -2) { $this->errors[] = 'ErrorCustomerCodeRequired'; } - if ($rescode == -3) + elseif ($rescode == -3) { $this->errors[] = 'ErrorCustomerCodeAlreadyUsed'; } - if ($rescode == -4) + elseif ($rescode == -4) { $this->errors[] = 'ErrorPrefixRequired'; } @@ -677,15 +692,15 @@ class Societe extends CommonObject { $this->errors[] = 'ErrorBadSupplierCodeSyntax'; } - if ($rescode == -2) + elseif ($rescode == -2) { $this->errors[] = 'ErrorSupplierCodeRequired'; } - if ($rescode == -3) + elseif ($rescode == -3) { $this->errors[] = 'ErrorSupplierCodeAlreadyUsed'; } - if ($rescode == -5) + elseif ($rescode == -5) { $this->errors[] = 'ErrorprefixRequired'; } @@ -806,6 +821,8 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->skype = trim($this->skype); + $this->twitter = trim($this->twitter); + $this->facebook = trim($this->facebook); $this->url = $this->url?clean_url($this->url,0):''; $this->note_private = trim($this->note_private); $this->note_public = trim($this->note_public); @@ -929,6 +946,8 @@ class Societe extends CommonObject $sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null"); $sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null"); $sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null"); + $sql .= ",twitter = ".(! empty($this->twitter)?"'".$this->db->escape($this->twitter)."'":"null"); + $sql .= ",facebook = ".(! empty($this->facebook)?"'".$this->db->escape($this->facebook)."'":"null"); $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null"); @@ -1054,6 +1073,8 @@ class Societe extends CommonObject $lmember->address=$this->address; $lmember->email=$this->email; $lmember->skype=$this->skype; + $lmember->twitter=$this->twitter; + $lmember->facebook=$this->facebook; $lmember->phone=$this->phone; $result=$lmember->update($user,0,1,1,1); // Use nosync to 1 to avoid cyclic updates @@ -1064,7 +1085,7 @@ class Societe extends CommonObject $error++; } } - else if ($result < 0) + elseif ($result < 0) { $this->error=$lmember->error; $error++; @@ -1157,7 +1178,7 @@ class Societe extends CommonObject $sql .= ', s.status'; $sql .= ', s.price_level'; $sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif'; - $sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; + $sql .= ', s.phone, s.fax, s.email, s.skype, s.twitter, s.facebook, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; $sql .= ', s.capital, s.tva_intra'; $sql .= ', s.fk_typent as typent_id'; @@ -1250,6 +1271,8 @@ class Societe extends CommonObject $this->email = $obj->email; $this->skype = $obj->skype; + $this->twitter = $obj->twitter; + $this->facebook = $obj->facebook; $this->url = $obj->url; $this->phone = $obj->phone; $this->fax = $obj->fax; @@ -1960,37 +1983,37 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowCustomer") . ''; $linkstart = ''; $linkstart = ''; $linkstart = ''; $linkstart = ''; $linkstart = ''; $linkstart = ''; $linkstart = ''; $linkstart = 'trans("InActivity"); + elseif ($statut==1) return $langs->trans("InActivity"); } - if ($mode == 1) + elseif ($mode == 1) { if ($statut==0) return $langs->trans("ActivityCeased"); - if ($statut==1) return $langs->trans("InActivity"); + elseif ($statut==1) return $langs->trans("InActivity"); } - if ($mode == 2) + elseif ($mode == 2) { if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + elseif ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } - if ($mode == 3) + elseif ($mode == 3) { if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + elseif ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); } - if ($mode == 4) + elseif ($mode == 4) { if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + elseif ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } - if ($mode == 5) + elseif ($mode == 5) { if ($statut==0) return ''.$langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return ''.$langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + elseif ($statut==1) return ''.$langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); } - if ($mode == 6) + elseif ($mode == 6) { if ($statut==0) return ''.$langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return ''.$langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + elseif ($statut==1) return ''.$langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); } } @@ -3216,6 +3239,8 @@ class Societe extends CommonObject $this->phone=$member->phone; // Prof phone $this->email=$member->email; $this->skype=$member->skype; + $this->twitter=$member->twitter; + $this->facebook=$member->facebook; $this->client = 1; // A member is a customer by default $this->code_client = -1; @@ -3355,6 +3380,8 @@ class Societe extends CommonObject $this->country_code='FR'; $this->email='specimen@specimen.com'; $this->skype='tom.hanson'; + $this->twitter='tomhanson'; + $this->facebook='tomhanson'; $this->url='http://www.specimen.com'; $this->phone='0909090901'; diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 690eacd4037..422dd4ddb8e 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -422,37 +422,37 @@ class SocieteAccount extends CommonObject { $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 1) + elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 2) + elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 3) + elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); } - if ($mode == 4) + elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 5) + elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } - if ($mode == 6) + elseif ($mode == 6) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 6b5155321fe..970f3085392 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -84,10 +84,10 @@ $search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $search_categ_sup=trim(GETPOST("search_categ_sup",'int')); $search_country=GETPOST("search_country",'intcomma'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); +$search_staff=GETPOST("search_staff",'int'); $search_status=GETPOST("search_status",'int'); $search_type=GETPOST('search_type','alpha'); -$search_level_from = GETPOST("search_level_from","alpha"); -$search_level_to = GETPOST("search_level_to","alpha"); +$search_level = GETPOST("search_level", "array"); $search_stcomm=GETPOST('search_stcomm','int'); $search_import_key = GETPOST("search_import_key","alpha"); $search_btn=GETPOST('button_search','alpha'); @@ -184,6 +184,7 @@ $arrayfields=array( 's.phone'=>array('label'=>"Phone", 'checked'=>1), 's.fax'=>array('label'=>"Fax", 'checked'=>0), 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), + 'staff.code'=>array('label'=>"Staff", 'checked'=>0), 's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1), 's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2), 's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3), @@ -258,10 +259,10 @@ if (empty($reshook)) $search_vat=''; $search_type=''; $search_type_thirdparty=''; + $search_staff=''; $search_status=-1; $search_stcomm=''; - $search_level_from=''; - $search_level_to=''; + $search_level=''; $search_import_key=''; $toselect=''; $search_array_options=array(); @@ -318,80 +319,22 @@ if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$la if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects"); if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers"); -// If both parameters are set, search for everything BETWEEN them -if ($search_level_from != '' && $search_level_to != '') -{ - // Ensure that these parameters are numbers - $search_level_from = (int) $search_level_from; - $search_level_to = (int) $search_level_to; - - // If from is greater than to, reverse orders - if ($search_level_from > $search_level_to) - { - $tmp = $search_level_to; - $search_level_to = $search_level_from; - $search_level_from = $tmp; - } - - // Generate the SQL request - $sortwhere = '(sortorder BETWEEN '.$search_level_from.' AND '.$search_level_to.') AS is_in_range'; -} -// If only "from" parameter is set, search for everything GREATER THAN it -else if ($search_level_from != '') -{ - // Ensure that this parameter is a number - $search_level_from = (int) $search_level_from; - - // Generate the SQL request - $sortwhere = '(sortorder >= '.$search_level_from.') AS is_in_range'; -} -// If only "to" parameter is set, search for everything LOWER THAN it -else if ($search_level_to != '') -{ - // Ensure that this parameter is a number - $search_level_to = (int) $search_level_to; - - // Generate the SQL request - $sortwhere = '(sortorder <= '.$search_level_to.') AS is_in_range'; -} -// If no parameters are set, dont search for anything -else -{ - $sortwhere = '0 as is_in_range'; -} - // Select every potentiels, and note each potentiels which fit in search parameters -dol_syslog('societe/list.php',LOG_DEBUG); -$sql = "SELECT code, label, sortorder, ".$sortwhere; +$tab_level = array(); +$sql = "SELECT code, label, sortorder"; $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $sql.= " WHERE active > 0"; $sql.= " ORDER BY sortorder"; - $resql = $db->query($sql); if ($resql) { - $tab_level = array(); - $search_levels = array(); - while ($obj = $db->fetch_object($resql)) { // Compute level text $level=$langs->trans($obj->code); if ($level == $obj->code) $level=$langs->trans($obj->label); - - // Put it in the array sorted by sortorder - $tab_level[$obj->sortorder] = $level; - - // If this potentiel fit in parameters, add its code to the $search_levels array - if ($obj->is_in_range == 1) - { - $search_levels[] = '"'.preg_replace('[^A-Za-z0-9_-]', '', $obj->code).'"'; - } + $tab_level[$obj->code] = $level; } - - // Implode the $search_levels array so that it can be use in a "IN (...)" where clause. - // If no paramters was set, $search_levels will be empty - $search_levels = implode(',', $search_levels); } else dol_print_error($db); @@ -401,6 +344,7 @@ $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, $sql.= " s.tms as date_update, s.datec as date_creation,"; $sql.= " s.code_compta,s.code_compta_fournisseur,"; $sql.= " typent.code as typent_code,"; +$sql.= " staff.code as staff_code,"; $sql.= " country.code as country_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " region.code_region as region_code, region.nom as region_name"; @@ -419,6 +363,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; // We'll need this table joined to the select in order to filter by categ @@ -452,8 +397,8 @@ if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fourniss if ($search_town) $sql.= natural_search("s.town",$search_town); if (strlen($search_zip)) $sql.= natural_search("s.zip",$search_zip); if ($search_state) $sql.= natural_search("state.nom",$search_state); -if ($search_region) $sql.= natural_search("region.nom",$search_region); -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_region) $sql.= natural_search("region.nom",$search_region); +if ($search_country && $search_country != '-1') $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; if ($search_email) $sql.= natural_search("s.email",$search_email); if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone); if (strlen($search_fax)) $sql.= natural_search("s.phone", $search_fax); @@ -469,11 +414,12 @@ if (strlen($search_vat)) $sql.= natural_search("s.tva_intra",$search_vat); if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1"; if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; -if ($search_status!='' && $search_status >= 0) $sql .= " AND s.status = ".$db->escape($search_status); +if ($search_status!='' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2); if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode); -if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; -if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')'; -if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm",$search_stcomm,2); +if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql.= natural_search("s.fk_typent", $search_type_thirdparty, 2); +if (! empty($search_staff) && $search_staff != '-1') $sql.= natural_search("s.fk_effectif", $search_staff, 2); +if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3); +if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm", $search_stcomm, 2); if ($search_import_key) $sql.= natural_search("s.import_key",$search_import_key); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -566,13 +512,12 @@ if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6 if ($search_vat != '') $param.= '&search_vat='.urlencode($search_vat); if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); if ($search_type != '') $param.='&search_type='.urlencode($search_type); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if (is_array($search_level) && count($search_level)) foreach($search_level as $slevel) $param.='&search_level[]='.urlencode($slevel); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm); -if ($search_level_from != '') $param.='&search_level_from='.urlencode($search_level_from); -if ($search_level_to != '') $param.='&search_level_to='.urlencode($search_level_to); if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); if ($type != '') $param.='&type='.urlencode($type); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -796,6 +741,13 @@ if (! empty($arrayfields['typent.code']['checked'])) print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; } +// Staff +if (! empty($arrayfields['staff.code']['checked'])) +{ + print ''; +} if (! empty($arrayfields['s.email']['checked'])) { // Email @@ -888,37 +840,16 @@ if (! empty($arrayfields['customerorsupplier']['checked'])) print ''; print ''; } +// Prospect level if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) { - // Prospect level print ''; } - +// Prospect status if (! empty($arrayfields['s.fk_stcomm']['checked'])) { - // Prospect status print ''; } @@ -983,6 +914,7 @@ if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titr if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['staff.code']['checked'])) print_liste_field_titre($arrayfields['staff.code']['label'],$_SERVER["PHP_SELF"],"staff.code","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'],$_SERVER["PHP_SELF"],"s.fax","",$param,'',$sortfield,$sortorder); @@ -1131,6 +1063,15 @@ while ($i < min($num, $limit)) print ''; if (! $i) $totalarray['nbfield']++; } + // Staff + if (! empty($arrayfields['staff.code']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } if (! empty($arrayfields['s.email']['checked'])) { print "\n"; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index d855e89f712..604012a24c3 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -764,10 +764,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); if ($stripecu && $action != 'editkey_account') { - $url='https://dashboard.stripe.com/test/customers/'.$stripecu; + if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/'; + $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; if ($servicestatus) { - $url='https://dashboard.stripe.com/customers/'.$stripecu; + $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; } print ' '.img_picto($langs->trans('ShowInStripe'), 'object_globe').''; } diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index b5f0238e9a2..0f26bf0e11a 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2018 Thibault FOUCART * * 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 @@ -62,14 +62,16 @@ llxHeader('', $langs->trans("StripeChargeList")); if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha'))) { $service = 'StripeTest'; + $servicestatus = '0'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } else { $service = 'StripeLive'; + $servicestatus = '1'; } -$stripeaccount = $stripe->getStripeAccount($service); +$stripeacc = $stripe->getStripeAccount($service); /*if (empty($stripeaccount)) { print $langs->trans('ErrorStripeAccountNotDefined'); @@ -77,24 +79,24 @@ $stripeaccount = $stripe->getStripeAccount($service); if (!$rowid) { - print '
    '; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; $title=$langs->trans("StripeChargeList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeaccount.')':' (Stripe connection with keys from Stripe module setup)'); + $title.=($stripeacc?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); - print '
    '; - print '
    ".$langs->trans("Name")." / ".$langs->trans("Company")."Date".$langs->trans("Amount")."
    ".$langs->trans("Amount")."
    '.fieldLabel('EMail','email',$conf->global->SOCIETE_EMAIL_MANDATORY).'
    '.fieldLabel('Web','url').'
    '.fieldLabel('Skype','skype').'
    '.fieldLabel('Skype','skype').'skype).'">
    '.fieldLabel('Twitter','twitter').'twitter).'">
    '.fieldLabel('Facebook','facebook').'facebook).'">
    '.fieldLabel('AllocateCommercial','commercial_id').''; - $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); - print $form->multiselectarray('commercial', $userlist, GETPOST('commercial', 'array'), null, null, null, null, "90%"); - print '
    '.fieldLabel('AllocateCommercial','commercial_id').''; + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); + // Note: If user has no right to "see all thirdparties", we for selection of sale representative to him, so after creation he can see the record. + print $form->multiselectarray('commercial', $userlist, (count(GETPOST('commercial', 'array')) > 0?GETPOST('commercial', 'array'):(empty($user->rights->societe->client->voir)?array($user->id):array())), null, null, null, null, "90%"); + print '
    '.fieldLabel('Web','url').'
    '.fieldLabel('Skype','skype').'
    '.fieldLabel('Skype','skype').'
    '.fieldLabel('Twitter','twitter').'
    '.fieldLabel('Facebook','facebook').'
    '.fieldLabel('Phone','phone').''; + print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100'); + print ''; - $options_from = ''; // Generate in $options_from the list of each option sorted - foreach ($tab_level as $tab_level_sortorder => $tab_level_label) - { - $options_from .= ''; - } - array_reverse($tab_level, true); // Reverse the list - $options_to = ''; // Generate in $options_to the list of each option sorted in the reversed order - foreach ($tab_level as $tab_level_sortorder => $tab_level_label) - { - $options_to .= ''; - } - - // Print these two select - print $langs->trans("From").' '; - print ' '; - print $langs->trans("to").' '; - + print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print ''; $arraystcomm=array(); foreach($prospectstatic->cacheprospectstatus as $key => $val) @@ -950,7 +881,7 @@ if (! empty($arrayfields['s.tms']['checked'])) // Status if (! empty($arrayfields['s.status']['checked'])) { - print ''; + print ''; print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1); print ''; + if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1); + print $staffArray[$obj->staff_code]; + print '".$obj->email."
    '."\n"; + print '
    '; + print '
    '."\n"; - print ''; + print ''; print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); print_liste_field_titre("StripeCustomerId",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); print_liste_field_titre("Customer",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); @@ -103,13 +105,13 @@ if (!$rowid) print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"","","",'align="left"',$sortfield,$sortorder); print_liste_field_titre("Paid",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder); print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"'); - print "\n"; + print "\n"; - print "\n"; + print "\n"; - if ($stripeaccount) + if ($stripeacc) { - $list=\Stripe\Charge::all(array("limit" => $limit), array("stripe_account" => $stripeaccount)); + $list=\Stripe\Charge::all(array("limit" => $limit), array("stripe_account" => $stripeacc)); } else { @@ -146,18 +148,31 @@ if (!$rowid) $memberstatic->id = 0; } - print ''; + print ''; + + if (!empty($stripeacc)) $connect=$stripeacc.'/'; + // Ref - $url='https://dashboard.stripe.com/test/payments/'.$charge->id; + $url='https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id; if ($servicestatus) { - $url='https://dashboard.stripe.com/payments/'.$charge->id; + $url='https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id; } - print "\n"; + print "\n"; // Stripe customer - print "\n"; + print "\n"; // Link - print "\n"; + print "\n"; // Origine - print "\n"; + print "\n"; // Date payment - print '\n"; + print '\n"; // Type - print ''; + print ''; // Amount - print ""; + print ""; // Status - print '\n"; + print "\n"; - print "\n"; + print "\n"; } } else { diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 6560d42d137..fbf9784a6b3 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -1,14 +1,15 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2014 Raphaël Doursenaud - * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> - * Copyright (C) 2015 Juanjo Menent - * Copyright (C) 2018 ThibaultFOUCART +/* Copyright (C) 2001-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2018 ThibaultFOUCART + * Copyright (C) 2018 Frédéric France * * 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 @@ -47,9 +48,9 @@ $confirm = GETPOST('confirm'); $facid = GETPOST('facid','int'); $socname = GETPOST('socname'); -$source = GETPOST('source_id'); +$source = GETPOST('source_id'); $accountid = GETPOST('accountid'); -$paymentnum = GETPOST('num_paiement'); +$paymentnum = GETPOST('num_paiement'); $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); @@ -218,15 +219,12 @@ if (empty($reshook)) /* * Action add_paiement */ - if ($action == 'add_paiement') - { - if ($error) - { - $action = 'create'; - if (!$source) - { - setEventMessages($langs->transnoentities('NoSource'), null, 'errors'); - } + if ($action == 'add_paiement') { + if ($error) { + $action = 'create'; + if (!$source) { + setEventMessages($langs->transnoentities('NoSource'), null, 'errors'); + } $error++; } // Le reste propre a cette action s'affiche en bas de page. @@ -301,7 +299,7 @@ if (empty($reshook)) } elseif (preg_match('/src_/i',$source)) { - + $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); $src = $customer2->sources->retrieve("$source"); if ($src->type=='card') @@ -406,16 +404,14 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); -if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) -{ +if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) { $service = 'StripeLive'; $servicestatus = 0; -} -else { +} else { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); } @@ -568,7 +564,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '\n"; }*/ - // Third party + // Third party print '\n"; // Bank account @@ -583,22 +579,22 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Cheque number -// print ''; -// print ''; + //print ''; + //print ''; // Check transmitter -// print ''; -// print ''; + //print ''; + //print ''; // Bank name -// print ''; -// print ''; + //print ''; + //print ''; // Comments print ''; @@ -607,145 +603,155 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
    ".img_picto($langs->trans('ShowInStripe'), 'object_globe')." ".$charge->id."".img_picto($langs->trans('ShowInStripe'), 'object_globe')." ".$charge->id."".$charge->customer.""; + + if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/'; + $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer; + if ($servicestatus) + { + $url='https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer; + } + print ''.img_picto($langs->trans('ShowInStripe'), 'object_globe').' '.$charge->customer.''; + + print ""; + print ""; if ($societestatic->id > 0) { print $societestatic->getNomUrl(1); @@ -166,27 +181,27 @@ if (!$rowid) { print $memberstatic->getNomUrl(1); } - print ""; + print ""; if ($charge->metadata->dol_type=="order"){ $object = new Commande($db); $object->fetch($charge->metadata->dol_id); if ($object->id > 0) { - print "".img_picto('', 'object_order')." ".$object->ref.""; + print "".img_picto('', 'object_order')." ".$object->ref.""; } else print $FULLTAG; } elseif ($charge->metadata->dol_type=="invoice"){ $object = new Facture($db); $object->fetch($charge->metadata->dol_id); if ($object->id > 0) { - print "".img_picto('', 'object_invoice')." ".$object->ref.""; + print "".img_picto('', 'object_invoice')." ".$object->ref.""; } else print $FULLTAG; } else print $FULLTAG; - print "'.dol_print_date($charge->created,'%d/%m/%Y %H:%M')."'.dol_print_date($charge->created,'%d/%m/%Y %H:%M')."'; + print ''; if ($charge->source->object=='card') { print $langs->trans("card"); @@ -196,11 +211,11 @@ if (!$rowid) } elseif ($charge->source->type=='three_d_secure'){ print $langs->trans("card3DS"); } - print '".price(($charge->amount-$charge->amount_refunded)/100)."".price(($charge->amount-$charge->amount_refunded)/100, 0, '', 1, - 1, - 1, strtoupper($charge->currency))."'; + print ''; if ($charge->refunded=='1'){ print img_picto($langs->trans("refunded"),'statut6'); } elseif ($charge->paid=='1'){ @@ -213,9 +228,9 @@ if (!$rowid) $label.="Statut: ".$langs->trans("".$charge->outcome->seller_message.""); print $form->textwithpicto(img_picto($langs->trans("".$charge->status.""),'statut8'),$label,1); } - print "
    '.$langs->trans('Invoice').''.$facture->getNomUrl(4)."
    '.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
    '.$langs->trans('Numero'); -// print ' ('.$langs->trans("ChequeOrTransferNumber").')'; -// print '
    '.$langs->trans('Numero'); + //print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + //print '
    '.$langs->trans('CheckTransmitter'); -// print ' ('.$langs->trans("ChequeMaker").')'; -// print '
    '.$langs->trans('CheckTransmitter'); + //print ' ('.$langs->trans("ChequeMaker").')'; + //print '
    '.$langs->trans('Bank'); -// print ' ('.$langs->trans("ChequeBank").')'; -// print '
    '.$langs->trans('Bank'); + //print ' ('.$langs->trans("ChequeBank").')'; + //print '
    '.$langs->trans('Comments').'
    '; - dol_fiche_end(); + dol_fiche_end(); - $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); - print '
    '; - print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + print '
    '; + print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); - print ''."\n"; - // Titles with sort buttons - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - foreach ($customerstripe->sources->data as $src) { - print ''; + print '
    '.$langs->trans('Type').''.$langs->trans('Informations').'
    '."\n"; + // Titles with sort buttons + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + foreach ($customerstripe->sources->data as $src) { + print ''; print ''; -print ''; -print ''; + print' >'; + if ($src->object=='card') { + print img_credit_card($src->brand); + } elseif ($src->object=='source' && $src->type=='card') { + print img_credit_card($src->card->brand); + } elseif ($src->object=='source' && $src->type=='sepa_debit') { + print ''; + } + print ''; + print ''; // Default print ''; -print ''; -} -// TODO more dolibarize with new stripe function and stripeconnect -//if ($stripe->getStripeCustomerAccount($facture->socid)) { -//$account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); -//} + print ''; + } + // TODO more dolibarize with new stripe function and stripeconnect + //if ($stripe->getStripeCustomerAccount($facture->socid)) { + // $account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); + //} - if (($account->type=='custom' or $account->type=='express') && $entity==1) { - print ''; + if (($account->type=='custom' or $account->type=='express') && $entity==1) { + print ''; - print ''; + print ''; - print ''; - // Default - print ''; - print ''; - } - if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) - { - print ''; - } + print ''; + // Default + print ''; + print ''; + } + if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) { + print ''; + } - print "
    '.$langs->trans('Type').''.$langs->trans('Informations').'
    id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} -print'>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + print'class="opacitymedium"'; + } + print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print ' disabled'; } elseif (($customerstripe->default_source==$src->id && $action != 'add_paiement') or ($source==$src->id && $action == 'add_paiement')) { print ' checked'; } print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} + print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + print'class="opacitymedium"'; + } -print' >'; - if ($src->object=='card') - { - print img_credit_card($src->brand); - } - elseif ($src->object=='source' && $src->type=='card') - { - print img_credit_card($src->card->brand); - } - elseif ($src->object=='source' && $src->type=='sepa_debit') - { - print ''; - } -print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} -print' >'; -if ($src->object=='card'){ - print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; -print ''; - if ($src->country) - { - $img=picto_from_langcode($src->country); - print $img?$img.' ':''; - print getCountry($src->country,1); - } - else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; -} -elseif ($src->object=='source' && $src->type=='card'){ - print $src->owner->name.'
    ....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; -print '
    '; - if ($src->card->country) - { - $img=picto_from_langcode($src->card->country); - print $img?$img.' ':''; - print getCountry($src->card->country,1); - } - else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; -} -elseif ($src->object=='source' && $src->type=='sepa_debit'){ -print 'info sepa'; -print ''; - if ($src->sepa_debit->country) - { - $img=picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; - print getCountry($src->sepa_debit->country,1); - } - else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; -} -print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + print'class="opacitymedium"'; + } + print' >'; + if ($src->object=='card') { + print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; + print ''; + if ($src->country) { + $img = picto_from_langcode($src->country); + print $img?$img.' ':''; + print getCountry($src->country,1); + } else { + print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } + } elseif ($src->object=='source' && $src->type=='card') { + print $src->owner->name.'
    ....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; + print '
    '; + if ($src->card->country) { + $img = picto_from_langcode($src->card->country); + print $img?$img.' ':''; + print getCountry($src->card->country,1); + } else { + print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } + } elseif ($src->object=='source' && $src->type=='sepa_debit') { + print 'info sepa'; + print ''; + if ($src->sepa_debit->country) { + $img = picto_from_langcode($src->sepa_debit->country); + print $img?$img.' ':''; + print getCountry($src->sepa_debit->country,1); + } else { + print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + } + } + print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} -print'>'; + if (($action == 'add_paiement' && $src->id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + print'class="opacitymedium"'; + } + print'>'; if (($customerstripe->default_source==$src->id)) { print ""; } print '
    getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} - print'>global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { - print ' checked'; - } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) { - print ' disabled'; - } - print '>getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} - print '>getStripeCustomerAccount($facture->socid)!=$source) { + print'class="opacitymedium"'; + } + print'>global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { + print ' checked'; + } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) { + print ' disabled'; + } + print '>getStripeCustomerAccount($facture->socid)!=$source) { + print'class="opacitymedium"'; + } + print '>getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} - print'>'.$langs->trans('sold'); - print'id!=$source) { print'class="opacitymedium"';} - print'>'; + print 'getStripeCustomerAccount($facture->socid)!=$source) { + print'class="opacitymedium"'; + } + print'>'.$langs->trans('sold'); + print'id!=$source) { + print'class="opacitymedium"'; + } + print'>'; - print 'id!=$source) { print'class="opacitymedium"';} - print'>'; - // if (($customer->default_source!=$src->id)) { - // print img_picto($langs->trans("Disabled"),'off'); - // } else { - // print img_picto($langs->trans("Default"),'on'); - // } - print '
    '.$langs->trans("None").'
    id!=$source) { + print'class="opacitymedium"'; + } + print'>'; + //if (($customer->default_source!=$src->id)) { + // print img_picto($langs->trans("Disabled"),'off'); + //} else { + // print img_picto($langs->trans("Default"),'on'); + //} + print '
    '.$langs->trans("None").'
    "; + print ""; /* @@ -756,14 +762,14 @@ print ''; $sql.= ' f.datef as df, f.fk_soc as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { + if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } $sql.= ' WHERE f.entity = '.$conf->entity; $sql.= ' AND (f.fk_soc = '.$facture->socid; - if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { + if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; } @@ -802,20 +808,24 @@ print ''; $i = 0; //print ''; print '
    '; - print_barre_liste($langs->trans('StripeInvoiceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + print_barre_liste($langs->trans('StripeInvoiceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); print ''; print ''; print ''; print ''; - if (!empty($conf->multicurrency->enabled)) print ''; - if (!empty($conf->multicurrency->enabled)) print ''; - if (!empty($conf->multicurrency->enabled)) print ''; - if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + print ''; + print ''; + print ''; + } print ''; print ''; print ''; print ''; - if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } print ''; print "\n"; @@ -974,17 +984,21 @@ print ''; // Print total print ''; print ''; - if (!empty($conf->multicurrency->enabled)) print ''; - if (!empty($conf->multicurrency->enabled)) print ''; - if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + print ''; + print ''; + } print ''; print ''; - print ''; + print ''; print ''; - if (!empty($conf->multicurrency->enabled)) {print '';} + if (!empty($conf->multicurrency->enabled)) { + print ''; + } print "\n"; } print "
    '.$arraytitle.''.$langs->trans('Date').''.$langs->trans('Currency').''.$langs->trans('MulticurrencyAmountTTC').''.$multicurrencyalreadypayedlabel.''.$multicurrencyremaindertopay.''.$langs->trans('Currency').''.$langs->trans('MulticurrencyAmountTTC').''.$multicurrencyalreadypayedlabel.''.$multicurrencyremaindertopay.''.$langs->trans('AmountTTC').''.$alreadypayedlabel.''.$remaindertopay.''.$langs->trans('PaymentAmount').''.$langs->trans('MulticurrencyPaymentAmount').''.$langs->trans('MulticurrencyPaymentAmount').' 
    '.$langs->trans('TotalTTC').''.price($sign * $total_ttc).''.price($sign * $totalrecu); if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); if ($totalrecudeposits) print '+'.price($totalrecudeposits); print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).'
    "; @@ -1023,10 +1037,11 @@ print ''; $preselectedchoice=$addwarning?'no':'yes'; print '
    '; - if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); - if (!empty($multicurrency_totalpayment)) - { - $text.='
    '.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); + if (!empty($totalpayment)) { + $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); + } + if (!empty($multicurrency_totalpayment)) { + $text.='
    '.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 415ed32a62a..f95bde08369 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2018 Thibault FOUCART + * Copyright (C) 2018 Frédéric France * * 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 @@ -62,14 +63,16 @@ llxHeader('', $langs->trans("StripeTransactionList")); if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha'))) { $service = 'StripeTest'; + $servicestatus = '0'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } else { $service = 'StripeLive'; + $servicestatus = '1'; } -$stripeaccount = $stripe->getStripeAccount($service); +$stripeacc = $stripe->getStripeAccount($service); /*if (empty($stripeaccount)) { print $langs->trans('ErrorStripeAccountNotDefined'); @@ -77,41 +80,41 @@ $stripeaccount = $stripe->getStripeAccount($service); if (! $rowid) { - print ''; + print ''; if ($optioncss != '') - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; $title=$langs->trans("StripeTransactionList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeaccount.')':' (Stripe connection with keys from Stripe module setup)'); + $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); - print '
    '; - print '' . "\n"; + print '
    '; + print '
    ' . "\n"; - print ''; + print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); //print_liste_field_titre("StripeCustomerId",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); //print_liste_field_titre("CustomerId", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); - print_liste_field_titre("Origin", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); + //print_liste_field_titre("Origin", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "", "", "", 'align="left"', $sortfield, $sortorder); print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Fee", $_SERVER["PHP_SELF"], "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", 'align="right"'); - print "\n"; + print "\n"; - print "\n"; + print "\n"; - if ($stripeaccount) + if ($stripeacc) { - $txn = \Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeaccount)); + $txn = \Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeacc)); } else { @@ -155,14 +158,34 @@ if (! $rowid) { $societestatic->email = $obj->email; $societestatic->societe_id = $obj->fk_soc; - print ''; + print ''; // Ref - print "\n"; + if (!empty($stripeacc)) $connect=$stripeacc.'/'; + + // Ref + if (preg_match('/po_/i', $txn->source)){ + $origin="payouts"; + } elseif (preg_match('/fee_/i', $txn->source)) { + $origin="connect/application_fees"; + } else { + $origin="payments"; + } + + $url='https://dashboard.stripe.com/'.$connect.'test/'.$origin.'/'.$txn->source; + if ($servicestatus) { + $url='https://dashboard.stripe.com/'.$connect.$origin.'/'.$txn->source; + } + if ($txn->type == 'stripe_fee' || $txn->type == 'reserve_transaction') { + print ""; + } else { + print "\n"; + } + // Stripe customer - //print "\n"; + //print "\n"; // Link - /*print "\n";*/ + print "\n";*/ // Origine - print "\n"; + //print "\n"; // Date payment - print '\n"; + print '\n"; // Type - print ''; + print ''; // Amount - print ""; - print ""; + print ""; + print ""; // Status - print "'; - print "\n"; + print "'; + print "\n"; } - print "
    " . $txn->source . "".$txn->type."".img_picto($langs->trans('ShowInStripe'), 'object_globe')." " . $txn->source . "".$charge->customer."".$charge->customer.""; + /*print ""; if ($societestatic->id > 0) { print $societestatic->getNomUrl(1); @@ -171,37 +194,41 @@ if (! $rowid) { { print $memberstatic->getNomUrl(1); } - print ""; - print $FULLTAG; - if ($charge->metadata->source=="order"){ - $object = new Commande($db); - $object->fetch($charge->metadata->idsource); - print "".img_picto('', 'object_order')." ".$object->ref.""; - } elseif ($charge->metadata->source=="invoice"){ - $object = new Facture($db); - $object->fetch($charge->metadata->idsource); - print "".img_picto('', 'object_invoice')." ".$object->ref.""; - } - print ""; + ////if ($charge->metadata->dol_type=="order"){ + // $object = new Commande($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_order')." ".$object->ref.""; + //} elseif ($charge->metadata->dol_type=="invoice"){ + // $object = new Facture($db); + // $object->fetch($charge->metadata->dol_id); + // print "".img_picto('', 'object_invoice')." ".$object->ref.""; + //} + //print "' . dol_print_date($txn->created, '%d/%m/%Y %H:%M') . "' . dol_print_date($txn->created, '%d/%m/%Y %H:%M') . "' . $txn->type . '' . $txn->type . '" . price(($txn->amount) / 100) . "" . price(($txn->fee) / 100) . "" . price(($txn->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . "" . price(($txn->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($txn->currency)) . ""; - print $txn->status; - print '
    "; + if ($txn->status=='available') + {print img_picto($langs->trans("".$txn->status.""),'statut4');} + elseif ($txn->status=='pending') + {print img_picto($langs->trans("".$txn->status.""),'statut7');} + elseif ($txn->status=='failed') + {print img_picto($langs->trans("".$txn->status.""),'statut8');} + print '
    "; - print '
    '; - print ''; -} else {} + print ""; + print '
    '; + print ''; +} // End of page llxFooter(); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index cbd9eaac58f..1aefc5f0d34 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1393,6 +1393,7 @@ if ($action == 'create') //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherProposals").')'; // Project if (! empty($conf->projet->enabled)) { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b4bed51a5e5..03abd661d7d 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -54,7 +54,7 @@ $colortexttitlenotab='100,60,20'; $colortexttitle='0,0,0'; $colortext='0,0,0'; $colortextlink='0,0,100'; -$fontsize='0.85em'; +$fontsize='0.86em'; $fontsizesmaller='0.75em'; if (defined('THEME_ONLY_CONSTANT')) return; @@ -497,6 +497,7 @@ input#onlinepaymenturl, input#directdownloadlink { } hr { border: 0; border-top: 1px solid #ccc; } +.tabBar hr { margin-top: 20px; margin-bottom: 17px; } .button, .buttonDelete, input[name="sbmtConnexion"] { margin-bottom: 0; @@ -1378,7 +1379,7 @@ div.nopadding { margin : 0px auto; } -#pictotitle { +.pictotitle { margin-: 8px; margin-bottom: 4px; } @@ -1836,6 +1837,7 @@ foreach($mainmenuusedarray as $val) position: absolute; height: 100%; width: 100%; + font-size: 1em; } .login_center { display: table-cell; @@ -1852,8 +1854,9 @@ form#login { } .login_table_title { max-width: 530px; - color: #aaa !important; + color: #eee !important; padding-bottom: 20px; + text-shadow: 1px 1px #444; } .login_table label { text-shadow: 1px 1px 1px #FFF; @@ -1888,12 +1891,30 @@ if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) { padding: 5px; margin-left: 5px; margin-top: 5px; + margin-bottom: 5px; } .login_table input#username:focus, .login_table input#password:focus, .login_table input#securitycode:focus { outline: none !important; - /* box-shadow: none; - -webkit-box-shadow: 0 0 0 50px #FFF inset; - box-shadow: 0 0 0 50px #FFF inset;*/ +} +.login_table .trinputlogin { + font-size: 1.2em; + margin: 8px; +} +.login_table .tdinputlogin { + background-color: transparent; + /* border: 2px solid #ccc; */ + min-width: 220px; + border-radius: 2px; +} +.login_table .tdinputlogin .fa { + padding-left: 10px; + width: 14px; +} +.login_table .tdinputlogin input#username, .login_table .tdinputlogin input#password { + font-size: 1em; +} +.login_table .tdinputlogin input#securitycode { + font-size: 1em; } .login_main_message { text-align: center; @@ -2328,7 +2349,7 @@ div.popuptab { padding-right: 5px; } div.tabsAction { - margin: 20px 0em 20px 0em; + margin: 20px 0em 30px 0em; padding: 0em 0em; text-align: right; } @@ -2707,7 +2728,9 @@ table.paddingtopbottomonly tr td { background: rgb() !important; } tr.liste_titre_filter td.liste_titre { -/* border-bottom: 1px solid #ddd; */ + /* border-bottom: 1px solid #ddd; */ + padding-top: 1px; + padding-bottom: 0px; } .liste_titre_create td, .liste_titre_create th, .liste_titre_create .tagtd { @@ -3226,8 +3249,9 @@ ul.noborder li:nth-child(even):not(.liste_titre) { margin-bottom: 5px; text-align: center; - background: #f8f8f8; + background: #fcfcfc; border: 1px solid #eee; + /* border-left: 6px solid #ddd; */ box-shadow: 1px 1px 8px #ddd; border-radius: 0px; } @@ -3275,9 +3299,11 @@ ul.noborder li:nth-child(even):not(.liste_titre) { } .thumbstat { flex: 1 1 110px; + margin-bottom: 8px; } .thumbstat150 { flex: 1 1 110px; + margin-bottom: 8px; } .dashboardlineindicator { float: left; @@ -3471,7 +3497,7 @@ div.warning { background: #fcf8e3; } div.warning a, div.info a, div.error a { - color: rgb(); + color: rgb(); } /* Error message */ @@ -4405,7 +4431,7 @@ td.gminorheading { .ecmfiletree { width: 99%; height: 99%; - background: #FFF; + /* background: #FFF; */ padding-left: 2px; font-weight: normal; } @@ -4902,7 +4928,81 @@ span.noborderoncategories { /* ============================================================================== */ -/* Multiselect with checkbox */ +/* External lib multiselect with checkbox */ +/* ============================================================================== */ + +.multi-select-container { + display: inline-block; + position: relative; +} + +.multi-select-menu { + position: absolute; + left: 0; + top: 0.8em; + float: left; + min-width: 100%; + background: #fff; + margin: 1em 0; + padding: 0.4em 0; + border: 1px solid #aaa; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); + display: none; +} + +.multi-select-menu input { + margin-right: 0.3em; + vertical-align: 0.1em; +} + +.multi-select-button { + display: inline-block; + max-width: 20em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + vertical-align: middle; + background-color: #fff; + cursor: default; + + border: none; + border-bottom: solid 1px rgba(0,0,0,.2); + padding: 5px; + padding-left: 2px; + height: 17px; +} +.multi-select-button:focus { + outline: none; + border-bottom: 1px solid #666; +} + +.multi-select-button:after { + content: ""; + display: inline-block; + width: 0; + height: 0; + border-style: solid; + border-width: 0.5em 0.23em 0em 0.23em; + border-color: #444 transparent transparent transparent; + margin-left: 0.4em; +} + +.multi-select-container--open .multi-select-menu { display: block; } + +.multi-select-container--open .multi-select-button:after { + border-width: 0 0.4em 0.4em 0.4em; + border-color: transparent transparent #999 transparent; +} + +.multi-select-menuitem { + clear: both; + float: left; + padding-left: 5px +} + + +/* ============================================================================== */ +/* Native multiselect with checkbox */ /* ============================================================================== */ ul.ulselectedfields { @@ -4942,10 +5042,10 @@ dl.dropdown { } .dropdown dd ul { background-color: #FFF; - border: 1px solid #888; + box-shadow: 1px 1px 10px #aaa; display:none; :0px; /* pop is align on right */ - padding: 2px 15px 2px 5px; + padding: 0 0 0 0; position:absolute; top:2px; list-style:none; @@ -4955,10 +5055,13 @@ dl.dropdown { .dropdown dd ul li { white-space: nowrap; font-weight: normal; - padding: 2px; + padding: 4px 8px 4px 8px; /* color: rgb(); */ color: #000; } +.dropdown dd ul li:hover { + background: #eee; +} .dropdown dd ul li input[type="checkbox"] { margin-: 3px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index bb75cde5332..d88a84c5090 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -55,7 +55,7 @@ $colortexttitlenotab='90,90,90'; $colortexttitle='20,20,20'; $colortext='0,0,0'; $colortextlink='0,0,120'; -$fontsize='13'; +$fontsize='14'; $fontsizesmaller='11'; if (defined('THEME_ONLY_CONSTANT')) return; @@ -121,7 +121,7 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card $conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234'; $conf->global->THEME_ELDY_TEXT='0,0,0'; - $conf->global->THEME_ELDY_FONT_SIZE1='13'; + $conf->global->THEME_ELDY_FONT_SIZE1='14'; $conf->global->THEME_ELDY_FONT_SIZE2='11'; } @@ -1372,7 +1372,7 @@ table.noborder tr.liste_titre td { margin : 0px auto; } -#pictotitle { +.pictotitle { margin-: 8px; margin-bottom: 4px; } @@ -1875,17 +1875,29 @@ form#login { } .login_table input#username, .login_table input#password, .login_table input#securitycode{ border: none; - border-bottom: solid 1px rgba(180,180,180,.4); + /* border-bottom: solid 1px rgba(180,180,180,.4); */ padding: 5px; margin-left: 18px; margin-top: 5px; + margin-bottom: 5px; } .login_table input#username:focus, .login_table input#password:focus, .login_table input#securitycode:focus { outline: none !important; - /* box-shadow: none; - -webkit-box-shadow: 0 0 0 50px #FFF inset; - box-shadow: 0 0 0 50px #FFF inset;*/ } +.login_table .trinputlogin { + margin: 8px; +} +.login_table .tdinputlogin { + background-color: #fff; + border: 2px solid #ccc; + min-width: 220px; + border-radius: 2px; +} +.login_table .tdinputlogin .fa { + padding-left: 10px; + width: 14px; +} + .login_main_message { text-align: center; max-width: 570px; @@ -2673,6 +2685,8 @@ table.paddingtopbottomonly tr td { } tr.liste_titre_filter td.liste_titre { border-bottom: 1px solid #FDFFFF; + padding-top: 4px; + padding-bottom: 3px; } .liste_titre_create td, .liste_titre_create th, .liste_titre_create .tagtd { @@ -2704,7 +2718,7 @@ table.liste td, table.noborder td, div.noborder form div { padding: 8px 6px 8px 6px; /* t r b l */ } div.liste_titre_bydiv .divsearchfield { - padding: 2px 1px 2px 0px; /* t r b l */ + padding: 2px 1px 2px 6px; /* t r b l */ } table.nobordernopadding { @@ -3385,7 +3399,7 @@ div.warning { background: #fcf8e3; } div.warning a, div.info a, div.error a { - color: rgb(); + color: rgb(); } /* Error message */ @@ -4760,7 +4774,81 @@ span.noborderoncategories { /* ============================================================================== */ -/* Multiselect with checkbox */ +/* External lib multiselect with checkbox */ +/* ============================================================================== */ + +.multi-select-container { + display: inline-block; + position: relative; +} + +.multi-select-menu { + position: absolute; + left: 0; + top: 0.8em; + float: left; + min-width: 100%; + background: #fff; + margin: 1em 0; + padding: 0.4em 0; + border: 1px solid #aaa; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); + display: none; +} + +.multi-select-menu input { + margin-right: 0.3em; + vertical-align: 0.1em; +} + +.multi-select-button { + display: inline-block; + max-width: 20em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + vertical-align: middle; + background-color: #fff; + cursor: default; + + border: none; + border-bottom: solid 1px rgba(0,0,0,.2); + padding: 5px; + padding-left: 2px; + height: 17px; +} +.multi-select-button:focus { + outline: none; + border-bottom: 1px solid #666; +} + +.multi-select-button:after { + content: ""; + display: inline-block; + width: 0; + height: 0; + border-style: solid; + border-width: 0.5em 0.23em 0em 0.23em; + border-color: #444 transparent transparent transparent; + margin-left: 0.4em; +} + +.multi-select-container--open .multi-select-menu { display: block; } + +.multi-select-container--open .multi-select-button:after { + border-width: 0 0.4em 0.4em 0.4em; + border-color: transparent transparent #999 transparent; +} + +.multi-select-menuitem { + clear: both; + float: left; + padding-left: 5px +} + + +/* ============================================================================== */ +/* Native multiselect with checkbox */ /* ============================================================================== */ ul.ulselectedfields { @@ -4771,7 +4859,7 @@ dl.dropdown { padding:0px; margin-left: 2px; margin-right: 2px; - vertical-align: text-bottom; + vertical-align: middle; display: inline-block; } .dropdown dd, .dropdown dt { @@ -4800,7 +4888,7 @@ dl.dropdown { } .dropdown dd ul { background-color: #FFF; - border: 1px solid #888; + box-shadow: 1px 1px 10px #aaa; display:none; right:0px; /* pop is align on right */ padding: 2px 15px 2px 5px; @@ -4813,7 +4901,7 @@ dl.dropdown { .dropdown dd ul li { white-space: nowrap; font-weight: normal; - padding: 2px; + padding: 4px; color: #000; } .dropdown dd ul li input[type="checkbox"] { diff --git a/htdocs/ticket/class/ticketlogs.class.php b/htdocs/ticket/class/ticketlogs.class.php index c5e77bc9dae..01ba7972ced 100644 --- a/htdocs/ticket/class/ticketlogs.class.php +++ b/htdocs/ticket/class/ticketlogs.class.php @@ -75,7 +75,6 @@ class Ticketlogs// extends CommonObject public function __construct($db) { $this->db = $db; - return 1; } /** diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index b23b4c5d27e..b1fb2d31cef 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -219,8 +219,8 @@ foreach($search as $key => $val) if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'fk_statut')?2:$mode_search)); } if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); -if ($search_fk_soc) $sql.= natural_search('fk_soc', $search_fk_soc); -if ($search_fk_project) $sql.= natural_search('fk_project', $search_fk_project); +if ($search_fk_soc) $sql.= natural_search('fk_soc', $search_fk_soc, 2); +if ($search_fk_project) $sql.= natural_search('fk_project', $search_fk_project, 2); if (!$user->societe_id && ($mode == "my_assign" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { $sql.= " AND t.fk_user_assign=".$user->id; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 3f3e217dc04..9020cd3a4bc 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot - * Copyright (C) 2013-2014 Philippe Grand + * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2018 charlene Benke @@ -62,7 +62,7 @@ class User extends CommonObject public $birth; public $email; public $skype; - public $job; + public $job; // job position public $signature; public $address; public $zip; @@ -1853,7 +1853,7 @@ class User extends CommonObject function send_password($user, $password='', $changelater=0) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; global $dolibarr_main_url_root; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; @@ -1874,10 +1874,8 @@ class User extends CommonObject $outputlangs=$langs; } - $outputlangs->load("main"); - $outputlangs->load("errors"); - $outputlangs->load("users"); - $outputlangs->load("other"); + // Load translation files required by the page + $outputlangs->loadLangs(array("main", "errors", "users", "other")); $appli=constant('DOL_APPLICATION_TITLE'); if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; @@ -2169,9 +2167,7 @@ class User extends CommonObject */ function getPhotoUrl($width, $height, $cssclass='', $imagesize='') { - $result=''; - - $result.=''; + $result =''; $result.=Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize); $result.=''; @@ -2199,7 +2195,7 @@ class User extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if(!$user->rights->user->user->lire && $user->id !=$this->id) $option='nolink'; + if(!$user->rights->user->user->lire && $user->id !=$this->id) $option='nolink'; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; @@ -2348,7 +2344,7 @@ class User extends CommonObject $linkend=''; } - if ($option == 'nolink') + if ($option == 'nolink') { $linkstart = ''; $linkend=''; @@ -2388,34 +2384,33 @@ class User extends CommonObject if ($mode == 0) { - $prefix=''; if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } - if ($mode == 1) + elseif ($mode == 1) { if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } - if ($mode == 2) + elseif ($mode == 2) { if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); } - if ($mode == 3) + elseif ($mode == 3) { if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); } - if ($mode == 4) + elseif ($mode == 4) { if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); } - if ($mode == 5) + elseif ($mode == 5) { if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"'); - if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); + elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); } } @@ -2436,8 +2431,8 @@ class User extends CommonObject global $conf; $dn=''; if ($mode==0) $dn=$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN; - if ($mode==1) $dn=$conf->global->LDAP_USER_DN; - if ($mode==2) $dn=$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS]; + elseif ($mode==1) $dn=$conf->global->LDAP_USER_DN; + elseif ($mode==2) $dn=$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS]; return $dn; } @@ -2511,7 +2506,7 @@ class User extends CommonObject if (! empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) } // Set LDAP password if possible - else if ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password + elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password { if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) { @@ -2524,7 +2519,7 @@ class User extends CommonObject } } // Use $this->pass_indatabase value if exists - else if (! empty($this->pass_indatabase)) + elseif (! empty($this->pass_indatabase)) { if (! empty($conf->global->LDAP_FIELD_PASSWORD)) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte if (! empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption @@ -3020,7 +3015,7 @@ class User extends CommonObject public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { $tables = array( - 'user' + 'user', ); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); @@ -3077,7 +3072,7 @@ class User extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null) { - global $conf,$user,$langs; + global $conf, $user, $langs; $langs->load("user"); diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 78ef5b7a390..e3ada6efcac 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -1,11 +1,11 @@ - * Copyright (c) 2005-2018 Laurent Destailleur - * Copyright (c) 2005-2018 Regis Houssin - * Copyright (C) 2012 Florian Henry - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2014 Alexis Algoud - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (c) 2005 Rodolphe Quiedeville + * Copyright (c) 2005-2018 Laurent Destailleur + * Copyright (c) 2005-2018 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Alexis Algoud + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -46,6 +46,7 @@ class UserGroup extends CommonObject public $table_element='usergroup'; public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $picto='group'; /** @@ -53,16 +54,26 @@ class UserGroup extends CommonObject */ public $entity; - public $name; // Name of group /** + * @var string * @deprecated * @see name */ - public $nom; // Name of group + public $nom; + + /** + * @var string name + */ + public $name; // Name of group + public $globalgroup; // Global group + public $datec; // Creation date of group + public $datem; // Modification date of group + public $note; // Description + public $members=array(); // Array of users public $nb_rights; // Number of rights granted to the user diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 6cb418ff641..563ff54c490 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -110,6 +110,12 @@ if (empty($reshook)) { $tabparam["MAIN_SIZE_LISTE_LIMIT"] = ''; } + if (GETPOST("check_AGENDA_DEFAULT_VIEW") == "on") { + $tabparam["AGENDA_DEFAULT_VIEW"] = $_POST["AGENDA_DEFAULT_VIEW"]; + } else { + $tabparam["AGENDA_DEFAULT_VIEW"] = ''; + } + if (GETPOST("check_MAIN_THEME") == "on") { $tabparam["MAIN_THEME"] = $_POST["main_theme"]; } else { @@ -223,6 +229,9 @@ if ($action == 'edit') if (jQuery("#check_SIZE_LISTE_LIMIT").prop("checked")) { jQuery("#main_size_liste_limit").removeAttr(\'disabled\'); } else { jQuery("#main_size_liste_limit").attr(\'disabled\',\'disabled\'); } + if (jQuery("#check_AGENDA_DEFAULT_VIEW").prop("checked")) { jQuery("#AGENDA_DEFAULT_VIEW").removeAttr(\'disabled\'); } + else { jQuery("#AGENDA_DEFAULT_VIEW").attr(\'disabled\',\'disabled\'); } + if (jQuery("#check_MAIN_THEME").prop("checked")) { jQuery(".themethumbs").removeAttr(\'disabled\'); } else { jQuery(".themethumbs").attr(\'disabled\',\'disabled\'); } @@ -231,8 +240,9 @@ if ($action == 'edit') } init_myfunc(); jQuery("#check_MAIN_LANDING_PAGE").click(function() { init_myfunc(); }); - jQuery("#check_SIZE_LISTE_LIMIT").click(function() { init_myfunc(); }); jQuery("#check_MAIN_LANG_DEFAULT").click(function() { init_myfunc(); }); + jQuery("#check_SIZE_LISTE_LIMIT").click(function() { init_myfunc(); }); + jQuery("#check_AGENDA_DEFAULT_VIEW").click(function() { init_myfunc(); }); jQuery("#check_MAIN_THEME").click(function() { init_myfunc(); }); jQuery("#check_THEME_ELDY_TOPMENU_BACK1").click(function() { init_myfunc(); }); jQuery("#check_THEME_ELDY_BACKTITLE1").click(function() { init_myfunc(); }); @@ -251,7 +261,7 @@ if ($action == 'edit') print ''; print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE); print ''; - print 'conf->MAIN_LANDING_PAGE)?" checked":""); + print 'conf->MAIN_LANDING_PAGE)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; @@ -259,28 +269,40 @@ if ($action == 'edit') //print info_admin($langs->trans("WarningYouMayLooseAccess"), 0, 0, 0); print ''; - // Langue par defaut + // Language by default print ''.$langs->trans("Language").''; print ''; $s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT); print $s?$s.' ':''; print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT)); print ''; - print 'conf->MAIN_LANG_DEFAULT)?" checked":""); + print 'conf->MAIN_LANG_DEFAULT)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; print $formadmin->select_language((! empty($object->conf->MAIN_LANG_DEFAULT)?$object->conf->MAIN_LANG_DEFAULT:''),'main_lang_default',1,null,0,0,(! empty($dolibarr_main_demo))); print ''; - // Taille max des listes + // Max size of lists print ''.$langs->trans("MaxSizeList").''; print ''.$conf->global->MAIN_SIZE_LISTE_LIMIT.''; - print 'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":""); + print 'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; + // AGENDA_DEFAULT_VIEW + print ''."\n"; + print ''.$langs->trans("AGENDA_DEFAULT_VIEW").''."\n"; + print ' '."\n"; + print 'conf->AGENDA_DEFAULT_VIEW)?" checked":""); + print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo + print '> '.$langs->trans("UsePersonalValue").''; + print ''."\n"; + $tmplist=array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); + print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $object->conf->AGENDA_DEFAULT_VIEW, 0, 0, 0, ''); + print ''."\n"; + print '
    '; // Theme @@ -308,12 +330,11 @@ else print ''.$langs->trans("Parameter").''.$langs->trans("DefaultValue").' '.$langs->trans("PersonalValue").''; // Landing page - print ''.$langs->trans("LandingPage").''; print ''; print (empty($conf->global->MAIN_LANDING_PAGE)?'':$conf->global->MAIN_LANDING_PAGE); print ''; - print 'conf->MAIN_LANDING_PAGE)?" checked":""); + print 'conf->MAIN_LANDING_PAGE)?" checked":""); print empty($dolibarr_main_demo)?'':' disabled="disabled"'; // Disabled for demo print '> '.$langs->trans("UsePersonalValue").''; print ''; @@ -326,26 +347,35 @@ else print ''; // Language - print ''.$langs->trans("Language").''; print ''; $s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT); print ($s?$s.' ':''); print (isset($conf->global->MAIN_LANG_DEFAULT) && $conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT)); print ''; - print 'conf->MAIN_LANG_DEFAULT)?" checked":"").'> '.$langs->trans("UsePersonalValue").''; + print 'conf->MAIN_LANG_DEFAULT)?" checked":"").'> '.$langs->trans("UsePersonalValue").''; print ''; $s=(isset($object->conf->MAIN_LANG_DEFAULT) ? picto_from_langcode($object->conf->MAIN_LANG_DEFAULT) : ''); print ($s?$s.' ':''); print (isset($object->conf->MAIN_LANG_DEFAULT) && $object->conf->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):(! empty($object->conf->MAIN_LANG_DEFAULT)?$langs->trans("Language_".$object->conf->MAIN_LANG_DEFAULT):'')); print ''; - + // Max size for lists print ''.$langs->trans("MaxSizeList").''; print ''.(! empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?$conf->global->MAIN_SIZE_LISTE_LIMIT:' ').''; - print 'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"").'> '.$langs->trans("UsePersonalValue").''; + print 'conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"").'> '.$langs->trans("UsePersonalValue").''; print '' . (! empty($object->conf->MAIN_SIZE_LISTE_LIMIT)?$object->conf->MAIN_SIZE_LISTE_LIMIT:' ') . ''; + // AGENDA_DEFAULT_VIEW + print ''."\n"; + print ''.$langs->trans("AGENDA_DEFAULT_VIEW").''."\n"; + print ' '."\n"; + print 'conf->AGENDA_DEFAULT_VIEW)?" checked":"").'> '.$langs->trans("UsePersonalValue").''; + print ''."\n"; + $tmplist=array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); + if (! empty($object->conf->AGENDA_DEFAULT_VIEW)) print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $object->conf->AGENDA_DEFAULT_VIEW, 0, 0, 0, '', 0, 0, 1); + print ''."\n"; + print '
    '; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 1629a698673..adcfdd7309c 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1,10 +1,9 @@ +/* Copyright (C) 2007-2018 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018 Frédéric France - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 @@ -158,7 +157,7 @@ class Website extends CommonObject $sql.= 'status,'; $sql.= 'fk_default_home,'; $sql.= 'virtualhost,'; - $sql.= 'fk_user_create,'; + $sql.= 'fk_user_creat,'; $sql.= 'date_creation,'; $sql.= 'tms'; $sql .= ') VALUES ('; @@ -168,7 +167,7 @@ class Website extends CommonObject $sql .= ' '.(! isset($this->status)?'1':$this->status).','; $sql .= ' '.(! isset($this->fk_default_home)?'NULL':$this->fk_default_home).','; $sql .= ' '.(! isset($this->virtualhost)?'NULL':"'".$this->db->escape($this->virtualhost)."'").","; - $sql .= ' '.(! isset($this->fk_user_create)?$user->id:$this->fk_user_create).','; + $sql .= ' '.(! isset($this->fk_user_creat)?$user->id:$this->fk_user_creat).','; $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").","; $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_creation)."'"); $sql .= ')'; @@ -227,7 +226,7 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; @@ -253,7 +252,7 @@ class Website extends CommonObject $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; - $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); @@ -317,7 +316,7 @@ class Website extends CommonObject $sql .= " t.status,"; $sql .= " t.fk_default_home,"; $sql .= " t.virtualhost,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; @@ -357,7 +356,7 @@ class Website extends CommonObject $line->status = $obj->status; $line->fk_default_home = $obj->fk_default_home; $line->virtualhost = $obj->virtualhost; - $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $line->date_creation = $this->db->jdate($obj->date_creation); $line->date_modification = $this->db->jdate($obj->date_modification); @@ -639,10 +638,11 @@ class Website extends CommonObject if (! $error) { $filetpl=$pathofwebsitenew.'/page'.$newidforhome.'.tpl.php'; + $filewrapper=$pathofwebsitenew.'/wrapper.php'; // Generate the index.php page to be the home page //------------------------------------------------- - $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl); + $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl, $filewrapper); } } @@ -769,7 +769,7 @@ class Website extends CommonObject $this->status = ''; $this->fk_default_home = null; $this->virtualhost = 'http://myvirtualhost'; - $this->fk_user_create = $user->id; + $this->fk_user_creat = $user->id; $this->fk_user_modif = $user->id; $this->date_creation = dol_now(); $this->tms = dol_now(); @@ -783,7 +783,7 @@ class Website extends CommonObject */ function exportWebSite() { - global $conf; + global $conf, $mysoc; $website = $this; @@ -904,6 +904,9 @@ class Website extends CommonObject $stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport); $stringtoexport = str_replace('medias/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport); $stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_small, "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__", $stringtoexport); + $stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_mini, "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__", $stringtoexport); + $stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo, "file=logos%2Fthumbs%2F__LOGO_KEY__", $stringtoexport); $line.= "'".$this->db->escape(str_replace(array("\r\n","\r","\n"), "__N__", $stringtoexport))."', "; // Replace \r \n to have record on 1 line $stringtoexport = $objectpageold->content; @@ -912,6 +915,9 @@ class Website extends CommonObject $stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport); $stringtoexport = str_replace('medias/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport); $stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport); + $stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_small, "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__", $stringtoexport); + $stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_mini, "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__", $stringtoexport); + $stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo, "file=logos%2Fthumbs%2F__LOGO_KEY__", $stringtoexport); $line.= "'".$this->db->escape($stringtoexport)."'"; // Replace \r \n to have record on 1 line $line.= ");"; $line.= "\n"; @@ -951,7 +957,7 @@ class Website extends CommonObject */ function importWebSite($pathtofile) { - global $conf; + global $conf, $mysoc; $error = 0; @@ -1000,10 +1006,14 @@ class Website extends CommonObject $arrayreplacement['__WEBSITE_ID__'] = $object->id; $arrayreplacement['__WEBSITE_KEY__'] = $object->ref; $arrayreplacement['__N__'] = $this->db->escape("\n"); // Restore \n + $arrayreplacement['__LOGO_SMALL_KEY__'] = $this->db->escape($mysoc->logo_small); + $arrayreplacement['__LOGO_MINI_KEY__'] = $this->db->escape($mysoc->logo_mini); + $arrayreplacement['__LOGO_KEY__'] = $this->db->escape($mysoc->logo); $result = dolReplaceInFile($sqlfile, $arrayreplacement); $this->db->begin(); + // Search the $maxrowid because we need it later $sqlgetrowid='SELECT MAX(rowid) as max from '.MAIN_DB_PREFIX.'website_page'; $resql=$this->db->query($sqlgetrowid); if ($resql) @@ -1012,7 +1022,8 @@ class Website extends CommonObject $maxrowid=$obj->max; } - $runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1); + // Load sql record + $runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1); // The maxrowid of table is searched into this function two if ($runsql <= 0) { $this->errors[]='Failed to load sql file '.$sqlfile; @@ -1035,13 +1046,19 @@ class Website extends CommonObject $newid = ($reg[2] + $maxrowid); $aliasesarray = explode(',', $reg[3]); + $objectpagestatic->fetch($newid); + dol_syslog("Found ID ".$oldid." to replace with ID ".$newid." and shortcut aliases to create: ".$reg[3]); dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0); + // The move is not enough, so we regenerate page + $filetpl=$conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php'; + dolSavePageContent($filetpl, $object, $objectpagestatic); + + // Regenerate alternative aliases pages foreach($aliasesarray as $aliasshortcuttocreate) { - $objectpagestatic->id = $newid; $filealias=$conf->website->dir_output.'/'.$object->ref.'/'.$aliasshortcuttocreate.'.php'; dolSavePageAlias($filealias, $object, $objectpagestatic); } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index e60a0d2bcfe..97aba5e6ac2 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -1,9 +1,8 @@ +/* Copyright (C) 2007-2018 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 @@ -92,8 +91,8 @@ class WebsitePage extends CommonObject 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>502), - //'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510), - //'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1), ); @@ -130,7 +129,7 @@ class WebsitePage extends CommonObject * Load object in memory from the database * * @param int $id Id object. - * - If this is 0, the value into $page will be used. If not found of $page not defined, the default page of website_id will be used or the first page found if not set. + * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. * - If value is < 0, we must exclude this ID. * @param string $website_id Web site id (page name must also be filled if this parameter is used) * @param string $page Page name (website id must also be filled if this parameter is used) @@ -159,7 +158,7 @@ class WebsitePage extends CommonObject $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; //$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level @@ -202,7 +201,7 @@ class WebsitePage extends CommonObject $this->grabbed_from = $obj->grabbed_from; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->fk_user_create = $obj->fk_user_create; + $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; } $this->db->free($resql); @@ -255,7 +254,7 @@ class WebsitePage extends CommonObject $sql .= " t.grabbed_from,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; - $sql .= " t.fk_user_create,"; + $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; $sql .= ' WHERE t.fk_website = '.$websiteid; @@ -271,11 +270,11 @@ class WebsitePage extends CommonObject } } if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); + $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield,$sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { $sql .= ' ' . $this->db->plimit($limit, $offset); @@ -305,7 +304,7 @@ class WebsitePage extends CommonObject $record->grabbed_from = $obj->grabbed_from; $record->date_creation = $this->db->jdate($obj->date_creation); $record->date_modification = $this->db->jdate($obj->date_modification); - $record->fk_user_create = $obj->fk_user_create; + $record->fk_user_creat = $obj->fk_user_creat; $record->fk_user_modif = $obj->fk_user_modif; //var_dump($record->id); $records[$record->id] = $record; @@ -401,7 +400,7 @@ class WebsitePage extends CommonObject $object->ref = $newref; $object->pageurl = $newref; $object->aliasalt = ''; - $object->fk_user_create = $user->id; + $object->fk_user_creat = $user->id; $object->title = ($keeptitleunchanged ? '' : $langs->trans("CopyOf").' ').$object->title; if (! empty($newlang)) $object->lang=$newlang; if ($istranslation) $object->fk_page = $fromid; @@ -555,6 +554,6 @@ class WebsitePage extends CommonObject $this->grabbed_from = ''; $this->date_creation = $now - (24 * 30 * 3600); $this->date_modification = $now - (24 * 7 * 3600); - $this->fk_user_create = $user->id; + $this->fk_user_creat = $user->id; } } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 590423de2e4..c3facf51551 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -109,28 +109,55 @@ if ($websitekey) } $website = $object; +// Check pageid received as aprameter if ($pageid < 0) $pageid = 0; if (($pageid > 0 || $pageref) && $action != 'addcontainer') { $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); - //var_dump($res);exit; - //if ($res == 0) // Page ref not found, we check in alias - //{ - // $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); - //} // Check if pageid is inside the new website, if not we reset param pageid - if ($object->id > 0 && ($objectpage->fk_website != $object->id)) + if ($res >= 0 && $object->id > 0) { - $res = $objectpage->fetch(0, $object->id, '');; - if ($res == 0) // Page was not found, we reset it + if ($objectpage->fk_website != $object->id) // We have a bad page. { - $objectpage=new WebsitePage($db); + $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site + if ($res == 0) // Page was not found, we reset it + { + $objectpage=new WebsitePage($db); + } + else // We found a page, we set pageid to it. + { + $pageid = $objectpage->id; + } + } + else // We have a valid page. We force pageid for the case we got the page with a fetch on ref. + { + $pageid = $objectpage->id; } } - $pageid = $objectpage->id; } +// Define pageid if pageid and pageref not received as parameter or was wrong +if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createcontainer') +{ + $pageid = $object->fk_default_home; + if (empty($pageid)) + { + $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); + if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + $atleastonepage=(is_array($array) && count($array) > 0); + + $firstpageid=0;$homepageid=0; + foreach($array as $key => $valpage) + { + if (empty($firstpageid)) $firstpageid=$valpage->id; + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; + } + $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page + } +} + + global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/website/'.$websitekey; $filehtmlheader=$pathofwebsite.'/htmlheader.html'; @@ -180,6 +207,7 @@ if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfil if ($action == 'seteditinline') { dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1); + setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings'); dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of show included containers header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website','alphanohtml').'&pageid='.GETPOST('pageid','int')); exit; @@ -360,7 +388,7 @@ if ($action == 'addcontainer') // Remove comments $tmp['content'] = removeHtmlComment($tmp['content']); - preg_match('/(.*)<\/head>/is', $tmp['content'], $reg); + preg_match('/(.*)<\/head>/ims', $tmp['content'], $reg); $head = $reg[1]; $objectpage->type_container = 'page'; @@ -820,7 +848,7 @@ if ($action == 'updatecss') /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. $htmlheadercontent.= "begin(); + $objectnew = new Website($db); $result = $objectnew->createFromClone($user, GETPOST('id','int'), GETPOST('siteref','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):'')); if ($result < 0) @@ -1210,6 +1240,8 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $error++; setEventMessages($objectnew->error, $objectnew->errors, 'errors'); $action='preview'; + + $db->rollback(); } else { @@ -1217,6 +1249,8 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $id = $object->id; $pageid = $object->fk_default_home; $websitekey = GETPOST('siteref','aZ09'); + + $db->commit(); } } @@ -1235,17 +1269,51 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if (! $error) { + $db->begin(); + + $newwebsiteid = GETPOST('newwebsite','int'); + $pathofwebsitenew = $pathofwebsite; + + $tmpwebsite=new Website($db); + if ($newwebsiteid > 0 && $newwebsiteid != $object->id) + { + $tmpwebsite->fetch($newwebsiteid); + $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.$tmpwebsite->ref; + } + else + { + $tmpwebsite = $object; + } + $objectpage = new WebsitePage($db); - $result = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):''), $istranslation, GETPOST('newwebsite','int')); - if ($result < 0) + $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):''), $istranslation, $newwebsiteid); + if ($resultpage < 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); $action='createpagefromclone'; + + $db->rollback(); } else { - // TODO Switch on the new page ? + $fileindex=$pathofwebsitenew.'/index.php'; + $filetpl=$pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; + $filewrapper=$pathofwebsitenew.'/wrapper.php'; + + //var_dump($pathofwebsitenew); + //var_dump($filetpl); + //exit; + + dolSavePageContent($filetpl, $tmpwebsite, $resultpage); + + // Switch on the new page if web site of new page/container is same + if (empty($newwebsiteid) || $newwebsiteid == $object->id) + { + $pageid = $resultpage->id; + } + + $db->commit(); } } } @@ -1299,7 +1367,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $objectpage->content = GETPOST('PAGE_CONTENT','none'); // Clean data. We remove all the head section. - $objectpage->content = preg_replace('/.*<\/head>/s', '', $objectpage->content); + $objectpage->content = preg_replace('/.*<\/head>/ims', '', $objectpage->content); /* $objectpage->content = preg_replace('//s', '', $objectpage->content); */ @@ -1566,7 +1634,7 @@ if (! GETPOST('hide_websitemenu')) //var_dump($objectpage);exit; print '
    '; -if (count($object->records) > 0) +if (count($object->records) > 0) // There is at least one web site { // ***** Part for web sites @@ -1662,7 +1730,8 @@ if (count($object->records) > 0) print '
    '; - // Toolbar for website + // Toolbar for websites + print '
    '; if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') @@ -1762,7 +1831,7 @@ if (count($object->records) > 0) $out.=''; @@ -2319,6 +2388,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print $langs->trans("URL"); print ''; + print info_admin($langs->trans("OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0, 'warning'); print ' '; print ' '.$langs->trans("GrabImagesInto"); print ' '; @@ -2327,7 +2397,6 @@ if ($action == 'editmeta' || $action == 'createcontainer') print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto')?GETPOST('grabimagesinto'):'root'); print '
    '; print ''; - print '
    '.info_admin($langs->trans("OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0, '1'); print ''; print ''; @@ -2347,7 +2416,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print ''; - print $langs->trans('WEBSITE_PAGEURL'); + print $langs->trans('InternalURLOfPage'); print ''; print '/public/website/index.php?website='.urlencode($websitekey).'&pageid='.urlencode($pageid); print ''; @@ -2368,10 +2437,15 @@ if ($action == 'editmeta' || $action == 'createcontainer') $pagekeywords=$objectpage->keywords; $pagelang=$objectpage->lang; $pagehtmlheader=$objectpage->htmlheader; + $pagedatecreation=$objectpage->date_creation; + $pagedatemodification=$objectpage->date_modification; + $pageauthorid=$objectpage->fk_user_create; } else { $type_container = 'page'; + $pagedatecreation=dol_now(); + $pageauthorid=$user->id; } if (GETPOST('WEBSITE_TITLE','alpha')) $pagetitle=GETPOST('WEBSITE_TITLE','alpha'); if (GETPOST('WEBSITE_PAGENAME','alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME','alpha'); @@ -2395,6 +2469,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print ''; + // Type of container print ''; print $langs->trans('WEBSITE_TYPE_CONTAINER'); print ''; @@ -2435,13 +2510,37 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print ''; + $fuser=new User($db); + $fuser->fetch($pageauthorid); + + print ''; + print $langs->trans('Author'); + print ''; + if ($pageauthorid > 0) print $fuser->getNomUrl(1); + print ''; + + print ''; + print $langs->trans('DateCreation'); + print ''; + print dol_print_date($pagedatecreation, 'dayhour'); + print ''; + + if ($action != 'createcontainer') + { + print ''; + print $langs->trans('DateModification'); + print ''; + print dol_print_date($pagedatemodification, 'dayhour'); + print ''; + } + print ''; $htmlhelp=$langs->trans("EditTheWebSiteForACommonHeader").'

    '; $htmlhelp=$langs->trans("Example").' :
    '; $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); print $form->textwithpicto($langs->trans('HtmlHeaderPage'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); print ''; - $doleditor=new DolEditor('htmlheader', $pagehtmlheader, '', '180', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor=new DolEditor('htmlheader', $pagehtmlheader, '', '120', 'ace', 'In', true, false, 'ace', ROWS_3, '100%', ''); print $doleditor->Create(1, '', true, 'HTML Header', 'html'); print ''; @@ -2507,31 +2606,34 @@ if ($action == 'editmenu') if ($action == 'editsource') { - /* - * Editing with source editor - */ + // Editing with source editor $contentforedit = ''; - /*$contentforedit.=''."\n";*/ + //$contentforedit.=''."\n"; $contentforedit .= $objectpage->content; - + //var_dump($_SESSION["dol_screenheight"]); + $maxheightwin=480; + if (isset($_SESSION["dol_screenheight"])) + { + if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"]-400; + if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"]-490; + } + //var_dump($_SESSION["dol_screenheight"]); require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,'ace',ROWS_5,'90%'); + $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',$maxheightwin,'Full','',true,true,'ace',ROWS_5,'40%'); $doleditor->Create(0, '', false, 'HTML Source', 'php'); } -if ($action == 'editcontent') +/*if ($action == 'editcontent') { - /* - * Editing with default ckeditor - */ + // Editing with default ckeditor $contentforedit = ''; - /*$contentforedit.=''."\n";*/ + //$contentforedit.=''."\n"; $contentforedit .= $objectpage->content; $contentforedit = preg_replace('/(Create(0, '', false); -} +}*/ print "
    \n\n"; @@ -2556,16 +2658,21 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $objectpage->fetch($pageid); $jscontent = @file_get_contents($filejs); - $out = ''."\n"; + $out = ''."\n"; // Include a html so we can benefit of the header of page. // Note: We can't use iframe as it can be used to include another external html file // Note: We can't use frame as it is deprecated. + /*if ($includepageintoaframeoradiv == 'iframe') + { + $out .= "