From c18a8bef1b349d6db558d229b001f07045e27316 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 29 Jan 2019 19:44:59 +0100 Subject: [PATCH 01/99] Update eldy.lib.php Simplifying horizontal menu writing, it would simplify menu updates in the future. The menu table can be further simplified, it's in a 2nd step if @eldy confirms this restructuring. Already tested and it works. --- htdocs/core/menus/standard/eldy.lib.php | 584 +++++++++++++++--------- 1 file changed, 361 insertions(+), 223 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1de907face7..ef1ce0c8d85 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -65,246 +65,384 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } - // Home - $showmode=1; - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='home'; - - $titlehome = $langs->trans("Home"); - if (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) $titlehome = '   '; - $menu->add('/index.php?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname); + // Home + $menu_arr[] = array( + 'name' => 'Home', + 'link' => '/index.php?mainmenu=home&leftmenu=home', + 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)? '   ' : "Home") , + 'level' => 0, + 'enabled' => $showmode = 1, + 'target' => $atarget, + 'mainmenu' => "home", + 'leftmenu' => '', + 'position' => 10, + 'id' => $id, + 'idsel' => 'home', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home" ) ? 0 : 1 ), + 'loadLangs' => array(), + 'submenus' => array(), + ); // Members - $tmpentry = array( - 'enabled'=>(! empty($conf->adherent->enabled)), - 'perms'=>(! empty($user->rights->adherent->lire)), - 'module'=>'adherent', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='members'; + $menu_arr[] = array( + 'name' => 'Members', + 'link' => '/adherents/index.php?mainmenu=members&leftmenu=', + 'title' => "MenuMembers", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled' => (! empty($conf->adherent->enabled) ) , + 'perms' => (! empty($user->rights->adherent->lire) ), + 'module' => 'adherent', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "members", + 'leftmenu' => '', + 'position' => 18, + 'id' => $id, + 'idsel' => 'members', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 0 : 1 ), + 'loadLangs' => array(), + 'submenus' => array(), + ); - $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 18, $id, $idsel, $classname); - } + // Third parties + $menu_arr[] = array( + 'name' => 'Companies', + 'link' => '/societe/index.php?mainmenu=companies&leftmenu=', + 'title' => "ThirdParties", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && + ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) + ) + || ! empty($conf->fournisseur->enabled) + ), + 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), + 'module'=>'societe|fournisseur', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "companies", + 'leftmenu' => '', + 'position' => 20, + 'id' => $id, + 'idsel' => 'companies', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies" ) ? 0 : 1 ), + 'loadLangs' => array("companies","suppliers"), + 'submenus' => array(), + ); - // Third parties - $tmpentry = array( - 'enabled'=>(( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)), - 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), - 'module'=>'societe|fournisseur', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - // Load translation files required by the page - $langs->loadLangs(array("companies","suppliers")); + // Products-Services + $menu_arr[] = array( + 'name' => 'Products', + 'link' => '/product/index.php?mainmenu=products&leftmenu=', + 'title' => (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) + ? ( array("TMenuProducts" , " | " ,"TMenuServices") ) + : (! empty($conf->product->enabled)? "TMenuProducts" : "TMenuServices" ), + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && + ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) + ) + || ! empty($conf->fournisseur->enabled) + ), + 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), + 'module'=>'product|service', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "products", + 'leftmenu' => '', + 'position' => 30, + 'id' => $id, + 'idsel' => 'products', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products" ) ? 0 : 1 ), + 'loadLangs' => array("products"), + 'submenus' => array(), + ); - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='companies'; - - $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname); - } - - // Products-Services - $tmpentry = array( - 'enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), - 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), - 'module'=>'product|service', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("products"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='products'; - - $chaine=""; - if (! empty($conf->product->enabled)) { - $chaine.=$langs->trans("TMenuProducts"); - } - if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) { - $chaine.=" | "; - } - if (! empty($conf->service->enabled)) { - $chaine.=$langs->trans("TMenuServices"); - } - - $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname); - } - - // Projects - $tmpentry=array('enabled'=>(! empty($conf->projet->enabled)), - 'perms'=>(! empty($user->rights->projet->lire)), - 'module'=>'projet'); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("projects"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='project'; - - $title = $langs->trans("LeadsOrProjects"); // Leads and opportunities by default - $showmodel = $showmodep = $showmode; - if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { - $title = $langs->trans("Projects"); - $showmodel = 0; - } - if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { - $title = $langs->trans("Leads"); - $showmodep = 0; - } - - $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $title, 0, $showmode, $atarget, "project", '', 35, $id, $idsel, $classname); - //$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=openedopp', $langs->trans("ListLeads"), 0, $showmodel & $conf->global->PROJECT_USE_OPPORTUNITIES, $atarget, "project", '', 70, $id, $idsel, $classname); - //$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=notopenedopp', $langs->trans("ListProjects"), 0, $showmodep, $atarget, "project", '', 70, $id, $idsel, $classname); - } + // Projects + $menu_arr[] = array( + 'name' => 'Projet', + 'link' => '/projet/index.php?mainmenu=project&leftmenu=', + 'title' => (empty($conf->global->PROJECT_USE_OPPORTUNITIES) || $conf->global->PROJECT_USE_OPPORTUNITIES == 2 ) + ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2)?"Leads":"Projects") + : "LeadsOrProjects", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0), + 'perms'=> (! empty($user->rights->projet->lire) ? 1 : 0), + 'module'=>'projet', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "project", + 'leftmenu' => '', + 'position' => 35, + 'id' => $id, + 'idsel' => 'project', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 0 : 1 ), + 'loadLangs' => array("projects"), + 'submenus' => array(), + ); // Commercial - $menuqualified=0; - if (! empty($conf->propal->enabled)) $menuqualified++; - if (! empty($conf->commande->enabled)) $menuqualified++; - if (! empty($conf->supplier_order->enabled)) $menuqualified++; - if (! empty($conf->supplier_proposal->enabled)) $menuqualified++; - if (! empty($conf->contrat->enabled)) $menuqualified++; - if (! empty($conf->ficheinter->enabled)) $menuqualified++; - $tmpentry = array( - 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), - 'module'=>'propal|commande|supplier_order|contrat|ficheinter', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("commercial"); + $menu_arr[] = array( + 'name' => 'Commercial', + 'link' => '/comm/index.php?mainmenu=commercial&leftmenu=', + 'title' => "Commercial", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->propal->enabled) || + ! empty($conf->commande->enabled) || + ! empty($conf->supplier_order->enabled) || + ! empty($conf->supplier_proposal->enabled) || + ! empty($conf->contrat->enabled) || + ! empty($conf->ficheinter->enabled) + )?1:0, + 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), + 'module'=>'propal|commande|supplier_order|contrat|ficheinter', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "commercial", + 'leftmenu' => '', + 'position' => 40, + 'id' => $id, + 'idsel' => 'commercial', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial" ) ? 0 : 1 ), + 'loadLangs' => array("commercial"), + 'submenus' => array(), + ); - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='commercial'; - - $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname); - } - - // Billing - Financial - $menuqualified=0; - if (! empty($conf->facture->enabled)) $menuqualified++; - if (! empty($conf->don->enabled)) $menuqualified++; - if (! empty($conf->tax->enabled)) $menuqualified++; - if (! empty($conf->salaries->enabled)) $menuqualified++; - if (! empty($conf->supplier_invoice->enabled)) $menuqualified++; - if (! empty($conf->loan->enabled)) $menuqualified++; - $tmpentry = array( - 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), - 'module'=>'facture|supplier_invoice|don|tax|salaries|loan', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("compta"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='billing'; - - $menu->add('/compta/index.php?mainmenu=billing&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "billing", '', 50, $id, $idsel, $classname); - } + // Billing - Financial + $menu_arr[] = array( + 'name' => 'Compta', + 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', + 'title' => "MenuFinancial", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->facture->enabled) || + ! empty($conf->don->enabled) || + ! empty($conf->tax->enabled) || + ! empty($conf->salaries->enabled) || + ! empty($conf->supplier_invoice->enabled) || + ! empty($conf->loan->enabled) + )?1:0, + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) + || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) + || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), + 'module'=>'facture|supplier_invoice|don|tax|salaries|loan', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "billing", + 'leftmenu' => '', + 'position' => 50, + 'id' => $id, + 'idsel' => 'billing', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing" ) ? 0 : 1 ), + 'loadLangs' => array("compta"), + 'submenus' => array(), + ); // Bank - $tmpentry = array( - 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), - 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), - 'module'=>'banque|prelevement', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - // Load translation files required by the page - $langs->loadLangs(array("compta","banks")); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='bank'; - - $menu->add('/compta/bank/list.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 52, $id, $idsel, $classname); - } + $menu_arr[] = array( + 'name' => 'Bank', + 'link' => '/compta/bank/list.php?mainmenu=bank&leftmenu=', + 'title' => "MenuBankCash", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), + 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), + 'module'=>'banque|prelevement', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "bank", + 'leftmenu' => '', + 'position' => 52, + 'id' => $id, + 'idsel' => 'bank', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 0 : 1 ), + + 'loadLangs' => array("compta","banks"), + 'submenus' => array(), + ); // Accounting - $menuqualified=0; - if (! empty($conf->comptabilite->enabled)) $menuqualified++; - if (! empty($conf->accounting->enabled)) $menuqualified++; - if (! empty($conf->asset->enabled)) $menuqualified++; - $tmpentry = array( - 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), - 'module'=>'comptabilite|accounting', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("compta"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='accountancy'; - - $menu->add('/accountancy/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuAccountancy"), 0, $showmode, $atarget, "accountancy", '', 54, $id, $idsel, $classname); - } + $menu_arr[] = array( + 'name' => 'Accounting', + 'link' => '/accountancy/index.php?mainmenu=accountancy&leftmenu=', + 'title' => "MenuAccountancy", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), + 'comptabilite|accounting', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "accountancy", + 'leftmenu' => '', + 'position' => 54, + 'id' => $id, + 'idsel' => 'accountancy', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 0 : 1 ), + + 'loadLangs' => array("compta"), + 'submenus' => array(), + ); // HRM - $tmpentry = array( - 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), - 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), - 'module'=>'hrm|holiday|deplacement|expensereport', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $langs->load("holiday"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='hrm'; - - $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname); - } + $menu_arr[] = array( + 'name' => 'HRM', + 'link' => '/hrm/index.php?mainmenu=hrm&leftmenu=', + 'title' => "HRM", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), + 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), + 'module'=>'hrm|holiday|deplacement|expensereport', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "hrm", + 'leftmenu' => '', + 'position' => 80, + 'id' => $id, + 'idsel' => 'hrm', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 0 : 1 ), + + 'loadLangs' => array("holiday"), + 'submenus' => array(), + ); // Tools - $tmpentry = array( - 'enabled'=>1, - 'perms'=>1, - 'module'=>'', - ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) + $menu_arr[] = array( + 'name' => 'Tools', + 'link' => '/core/tools.php?mainmenu=tools&leftmenu=', + 'title' => "Tools", + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>1, + 'perms'=>1, + 'module'=>'', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "tools", + 'leftmenu' => '', + 'position' => 90, + 'id' => $id, + 'idsel' => 'tools', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 0 : 1 ), + + 'loadLangs' => array("other"), + 'submenus' => array(), + ); + + // Add menus + foreach($menu_arr as $key => $smenu) { - $langs->load("other"); - - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='tools'; - - $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname); + $smenu = (object) $smenu; + + if( $smenu->enabled ) + { + if($langs->session) + { + $_SESSION['idmenu']=''; + } + + // Load Langue + if(! empty($smenu->loadLangs)) + { + $langs->loadLangs($smenu->loadLangs); + } + + // Trans title + $mtitle = ''; + if(is_array($smenu->title)) + { + foreach($smenu->title as $item) + { + $mtitle .= $langs->trans($item); + } + } + else + { + $mtitle = $langs->trans($smenu->title); + } + // Add item + $menu->add($smenu->link, $mtitle , $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix); + } } // Show personalized menus From f3c725f40f0980ae588ce02bbd5afbeece10865e Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 29 Jan 2019 21:36:52 +0100 Subject: [PATCH 02/99] Update eldy.lib.php fix travis --- htdocs/core/menus/standard/eldy.lib.php | 72 ++++++++++++------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index ef1ce0c8d85..5226fb7d6cc 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -65,7 +65,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } - // Home + // Home $menu_arr[] = array( 'name' => 'Home', 'link' => '/index.php?mainmenu=home&leftmenu=home', @@ -94,7 +94,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled' => (! empty($conf->adherent->enabled) ) , 'perms' => (! empty($user->rights->adherent->lire) ), 'module' => 'adherent', @@ -108,13 +108,13 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'id' => $id, 'idsel' => 'members', 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 'class="tmenusel"' : 'class="tmenu"', - 'prefix' => '', + 'prefix' => '', 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 0 : 1 ), 'loadLangs' => array(), 'submenus' => array(), ); - // Third parties + // Third parties $menu_arr[] = array( 'name' => 'Companies', 'link' => '/societe/index.php?mainmenu=companies&leftmenu=', @@ -123,10 +123,10 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=> ( ( ! empty($conf->societe->enabled) && + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) - ) + ) || ! empty($conf->fournisseur->enabled) ), 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), @@ -147,21 +147,21 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Products-Services + // Products-Services $menu_arr[] = array( 'name' => 'Products', 'link' => '/product/index.php?mainmenu=products&leftmenu=', - 'title' => (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) + 'title' => (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) ? ( array("TMenuProducts" , " | " ,"TMenuServices") ) : (! empty($conf->product->enabled)? "TMenuProducts" : "TMenuServices" ), 'level' => 0, 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=> ( ( ! empty($conf->societe->enabled) && + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) - ) + ) || ! empty($conf->fournisseur->enabled) ), 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), @@ -182,18 +182,18 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Projects + // Projects $menu_arr[] = array( 'name' => 'Projet', 'link' => '/projet/index.php?mainmenu=project&leftmenu=', - 'title' => (empty($conf->global->PROJECT_USE_OPPORTUNITIES) || $conf->global->PROJECT_USE_OPPORTUNITIES == 2 ) + 'title' => (empty($conf->global->PROJECT_USE_OPPORTUNITIES) || $conf->global->PROJECT_USE_OPPORTUNITIES == 2 ) ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2)?"Leads":"Projects") : "LeadsOrProjects", 'level' => 0, 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0), 'perms'=> (! empty($user->rights->projet->lire) ? 1 : 0), 'module'=>'projet', @@ -222,13 +222,13 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->propal->enabled) || - ! empty($conf->commande->enabled) || - ! empty($conf->supplier_order->enabled) || - ! empty($conf->supplier_proposal->enabled) || - ! empty($conf->contrat->enabled) || - ! empty($conf->ficheinter->enabled) + $tmpentry = array( + 'enabled'=>(! empty($conf->propal->enabled) || + ! empty($conf->commande->enabled) || + ! empty($conf->supplier_order->enabled) || + ! empty($conf->supplier_proposal->enabled) || + ! empty($conf->contrat->enabled) || + ! empty($conf->ficheinter->enabled) )?1:0, 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), 'module'=>'propal|commande|supplier_order|contrat|ficheinter', @@ -248,7 +248,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Billing - Financial + // Billing - Financial $menu_arr[] = array( 'name' => 'Compta', 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', @@ -257,16 +257,16 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->facture->enabled) || - ! empty($conf->don->enabled) || - ! empty($conf->tax->enabled) || - ! empty($conf->salaries->enabled) || - ! empty($conf->supplier_invoice->enabled) || - ! empty($conf->loan->enabled) + $tmpentry = array( + 'enabled'=>(! empty($conf->facture->enabled) || + ! empty($conf->don->enabled) || + ! empty($conf->tax->enabled) || + ! empty($conf->salaries->enabled) || + ! empty($conf->supplier_invoice->enabled) || + ! empty($conf->loan->enabled) )?1:0, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) - || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) + || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), 'module'=>'facture|supplier_invoice|don|tax|salaries|loan', ), @@ -294,7 +294,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), 'module'=>'banque|prelevement', @@ -325,7 +325,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)), 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), 'comptabilite|accounting', @@ -356,7 +356,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), 'module'=>'hrm|holiday|deplacement|expensereport', @@ -387,7 +387,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'enabled' => $showmode = isVisibleToUserType ( $type_user, - $tmpentry = array( + $tmpentry = array( 'enabled'=>1, 'perms'=>1, 'module'=>'', From 84d2bcce4faa6bb07672f8649c08b1c0059d0bce Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 29 Jan 2019 22:08:18 +0100 Subject: [PATCH 03/99] Update eldy.lib.php Fix Travis --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5226fb7d6cc..1da90af83e2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -441,7 +441,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $mtitle = $langs->trans($smenu->title); } // Add item - $menu->add($smenu->link, $mtitle , $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix); + $menu->add($smenu->link, $mtitle, $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix); } } From 12d7d3a6cbfed4dc13be0bdf0bb5a6bed6d17820 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Sat, 2 Mar 2019 09:54:32 +0100 Subject: [PATCH 04/99] retrieve latest branch --- htdocs/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/.gitignore b/htdocs/.gitignore index ac35d8fab2f..aa007a70ae5 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -28,3 +28,4 @@ /nomenclature* /of/ /workstation/ +/theme/dolipro* \ No newline at end of file From 3037e4a15730bd5f632f9902df631786123e64bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Mar 2019 20:49:53 +0100 Subject: [PATCH 05/99] Update DolibarrModules.class.php --- htdocs/core/modules/DolibarrModules.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 0140f850e34..9b9ed4f7a60 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -895,6 +895,8 @@ class DolibarrModules // Can not be abstract, because we need to insta { global $conf; + $err = 0; + $sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$conf->entity.")"; @@ -921,6 +923,8 @@ class DolibarrModules // Can not be abstract, because we need to insta { global $conf; + $err = 0; + $sql = "SELECT tms, note FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$conf->entity.")"; From 163faf24014854857ade3e97b11a504920161873 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Mon, 4 Mar 2019 11:19:54 +0100 Subject: [PATCH 06/99] Fix remove "canceled" invoices in margin by user --- htdocs/margin/agentMargins.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 687a381d790..d2d125f38c0 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -132,6 +132,8 @@ dol_fiche_end(); print ''; +$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); + $sql = "SELECT"; $sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; $sql.= " u.rowid as agent, u.login, u.lastname, u.firstname,"; @@ -153,7 +155,7 @@ if (! empty($conf->global->AGENT_CONTACT_TYPE)) $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; else $sql .= " AND sc.fk_user = u.rowid"; -$sql.= " AND f.fk_statut > 0"; +$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")"; $sql.= ' AND s.entity IN ('.getEntity('societe').')'; $sql.= " AND d.fk_facture = f.rowid"; if ($agentid > 0) { From 69794f5293dd8a47d7106fd056f5e7bec319d395 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 17:31:50 +0100 Subject: [PATCH 07/99] Fix phpcs --- htdocs/core/modules/DolibarrModules.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 8544cdb2416..a1ccb701a21 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -972,6 +972,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Insert constants for module activation * @@ -979,6 +980,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ protected function _active() { + // phpcs:enable global $conf, $user; $err = 0; @@ -1013,6 +1015,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Module deactivation * @@ -1020,6 +1023,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ protected function _unactive() { + // phpcs:enable global $conf; $err = 0; @@ -1039,6 +1043,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Create tables and keys required by module. * Files module.sql and module.key.sql with create table and create keys From 68bb95079ae6b1261b6a464c23eb3fd283500020 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 17:36:03 +0100 Subject: [PATCH 08/99] Ignore 2 rules --- htdocs/core/modules/DolibarrModules.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index a1ccb701a21..6e3bf7464b5 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1042,8 +1042,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Create tables and keys required by module. * Files module.sql and module.key.sql with create table and create keys From 0d49f278316b62685286c007ae77c8ecc24219ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 17:36:45 +0100 Subject: [PATCH 09/99] Code style --- htdocs/core/modules/DolibarrModules.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 6e3bf7464b5..193891d0b20 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1156,7 +1156,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } } - if (! $dirfound) { dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING); + if (! $dirfound) { + dol_syslog("A module ask to load sql files into ".$reldir." but this directory was not found.", LOG_WARNING); } return $ok; } From 8feca792f14479dfec6163e702966dbb78528e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 18:07:37 +0100 Subject: [PATCH 10/99] Update mouvementstock.class.php --- htdocs/product/stock/class/mouvementstock.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 39a9bb94bed..1135c0aa3fc 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -89,7 +89,8 @@ class MouvementStock extends CommonObject } - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** * Add a movement of stock (in one direction only) * * @param User $user User object @@ -111,8 +112,9 @@ class MouvementStock extends CommonObject * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) * @return int <0 if KO, 0 if fk_product is null, >0 if OK */ - private function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) + protected function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) { + // phpcs:enable global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; From 7bcc4e877553ea42f67a64fe0467befb77c8b7ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 18:21:48 +0100 Subject: [PATCH 11/99] Update mouvementstock.class.php --- htdocs/product/stock/class/mouvementstock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 1135c0aa3fc..99008aa9277 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -112,7 +112,7 @@ class MouvementStock extends CommonObject * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) * @return int <0 if KO, 0 if fk_product is null, >0 if OK */ - protected function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) + public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) { // phpcs:enable global $conf, $langs; From 5dc3cbcdfc9988de4c47c6b37bee56b6f17793fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 18:22:59 +0100 Subject: [PATCH 12/99] remove warning --- htdocs/theme/eldy/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index db4b494179d..30870438475 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1839,7 +1839,7 @@ a.tmenuimage { $found=1; break; } - else if (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + elseif (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité { $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); $found=1; From bdba88a6d56949ac1660ce00586f1a1d6ff0ca8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 18:23:52 +0100 Subject: [PATCH 13/99] remove warning --- htdocs/theme/md/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 85918a43245..781b72200b4 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1819,7 +1819,7 @@ foreach($mainmenuusedarray as $val) $found=1; break; } - else if (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + elseif (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité { $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); $found=1; From 4a582485b9f8c63260eb25e5c09dd9edcce76347 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 19:19:09 +0100 Subject: [PATCH 14/99] Debug module ticket --- htdocs/admin/ticket.php | 252 ++++-------------- htdocs/core/lib/ticket.lib.php | 6 + htdocs/core/modules/modTicket.class.php | 7 +- ...terface_50_modTicket_TicketEmail.class.php | 11 +- htdocs/langs/en_US/ticket.lang | 10 +- htdocs/public/ticket/index.php | 15 +- htdocs/ticket/class/ticket.class.php | 46 ---- htdocs/ticket/css/styles.css.php | 11 +- 8 files changed, 88 insertions(+), 270 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f94117ef747..052e11f1ced 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -19,7 +19,7 @@ /** * \file admin/ticket.php * \ingroup ticket - * \brief This file is a module setup page + * \brief Page to setup module ticket */ require '../main.inc.php'; @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; // Load translation files required by the page -$langs->load("ticket"); +$langs->loadLangs(array("admin", "ticket")); // Access control if (!$user->admin) { @@ -91,16 +91,6 @@ if ($action == 'updateMask') { $error++; } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); - if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); if (!empty($mail_intro)) { $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); @@ -121,36 +111,6 @@ if ($action == 'updateMask') { $error++; } - $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); if (!empty($text_help)) { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); @@ -163,26 +123,14 @@ if ($action == 'updateMask') { } if ($action == 'setvarother') { - $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } - $param_disable_email = GETPOST('TICKET_DISABLE_ALL_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - - $param_activate_log_by_email = GETPOST('TICKET_ACTIVATE_LOG_BY_EMAIL', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ACTIVATE_LOG_BY_EMAIL', $param_activate_log_by_email, 'chaine', 0, '', $conf->entity); + $param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } @@ -242,9 +190,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket"); -print $langs->trans("TicketSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; - -print $langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; +print ''.$langs->trans("TicketSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; dol_fiche_end(); @@ -353,80 +299,19 @@ if (!$conf->use_javascript_ajax) { print ''; print ''; } -print load_fiche_titre($langs->trans("TicketParamPublicInterface")); - -print ''; - -// Activate public interface -print ''; -print ''; -print ''; -print ''; - -// Check if email exists -print ''; -print ''; -print ''; -print ''; - -/*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) -{ - // Show logo for module - print ''; - print ''; - print ''; - print ''; -}*/ - -// Show logo for company -print ''; -print ''; -print ''; -print ''; - -print '
' . $langs->trans("TicketsActivatePublicInterface") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_ENABLE_PUBLIC_INTERFACE'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_ENABLE_PUBLIC_INTERFACE", $arrval, $conf->global->TICKET_ENABLE_PUBLIC_INTERFACE); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsActivatePublicInterfaceHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsEmailMustExist") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsShowModuleLogo") . ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); - print '
' . $langs->trans("TicketsShowCompanyLogo") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); -print '

'; print load_fiche_titre($langs->trans("TicketParams")); print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Activate email notifications -print ''; +/* +print ''; print ''; print ''; // Activate log by email -print ''; +print ''; print ''; print ''; +*/ // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; + print ''; print ''; +/* +print ''; print ''; print ''; +*/ -if (!$conf->use_javascript_ajax) { +/*if (!$conf->use_javascript_ajax) { print ''; print ''; -} +}*/ // Auto assign ticket at user who created it -print ''; +print ''; print ''; -print ''; -print ''; +print '
'; +print ''; +print '
'; -// Interface topic -$url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; -print ''; -print ''; -print ''; - -// Texte d'accueil homepage -$public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); -print ''; -print ''; - -// Texte d'aide à la saisie du message -$public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); -print ''; -print ''; - -print ''; -print ''; - -print '
' . $langs->trans("Parameter") . '
' . $langs->trans("TicketsDisableEmail") . '
' . $langs->trans("TicketsDisableEmail") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_DISABLE_ALL_MAILS'); @@ -441,7 +326,7 @@ print '
' . $langs->trans("TicketsLogEnableEmail") . '
' . $langs->trans("TicketsLogEnableEmail") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL'); @@ -454,11 +339,12 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help'); print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); @@ -474,7 +360,8 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } // Limiter la vue des tickets à ceux assignés à l'utilisateur -print '
' . $langs->trans("TicketsLimitViewAssignedOnly") . '
' . $langs->trans("TicketsLimitViewAssignedOnly") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_LIMIT_VIEW_ASSIGNED_ONLY'); @@ -487,14 +374,15 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketsLimitViewAssignedOnlyHelp"), 1, 'help'); print '
' . $langs->trans("TicketsAutoAssignTicket") . '
' . $langs->trans("TicketsAutoAssignTicket") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); @@ -515,7 +403,7 @@ if (!$conf->use_javascript_ajax) { } // Admin var of module -print load_fiche_titre($langs->trans("TicketParamMail")); +print load_fiche_titre($langs->trans("Notification")); print ''; @@ -533,17 +421,26 @@ if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print "\n"; } -// Email d'envoi des notifications -print ''; +// Activate log by email +/*print ''; print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL); +} +print ''; print ''; print ''; +*/ + +// @TODO Use module notification instead... // Email de réception des notifications -print ''; +print ''; print ''; print ''; print ''; -// Texte de création d'un ticket -$mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); -print ''; +// Email d'envoi des notifications +print ''; +print ''; print ''; +print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); +print ''; +print ''; // Texte d'introduction $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print ''; // Texte de signature $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText'); -print ''; -print ''; -print ''; -print "\n"; +print '
' . $langs->trans("TicketEmailNotificationFrom") . '
' . $langs->trans("TicketsLogEnableEmail") . ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); +print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help'); print '
' . $langs->trans("TicketEmailNotificationTo") . '
' . $langs->trans("TicketEmailNotificationTo") . ''; print ''; @@ -551,21 +448,18 @@ print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1 print '
' . $langs->trans("TicketNewEmailBodyLabel") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); -$doleditor->Create(); -print '
' . $langs->trans("TicketEmailNotificationFrom") . ''; +print ''; -print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); -print '
' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; +print '
' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; print ''; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); @@ -577,7 +471,7 @@ print '
' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; +print '
' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; print ''; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); @@ -587,58 +481,12 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help'); print '
' . $langs->trans("PublicInterface") . '
'; -// Url public interface -$url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; -print '
' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); -$doleditor->Create(); -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); -$doleditor->Create(); -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); -print '

'; print ''; // End of page diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 62615fb0ecd..406f53c4762 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -40,11 +40,17 @@ function ticketAdminPrepareHead() $head[$h][1] = $langs->trans("TicketSettings"); $head[$h][2] = 'settings'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsTicket"); $head[$h][2] = 'attributes'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_public.php'; + $head[$h][1] = $langs->trans("PublicInterface"); + $head[$h][2] = 'public'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line //$this->tabs = array( diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index e6deef76144..0ca3b3c99be 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -103,9 +103,10 @@ class modTicket extends DolibarrModules // List of particular constants to add when module is enabled // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // Example: - $this->const = array(); - $this->const[1] = array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '1', 'Enable ticket public interface'); - $this->const[2] = array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module'); + $this->const = array( + 1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0), + 2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0) + ); $this->tabs = array( 'thirdparty:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__', diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index c8a31a70e40..12baad3b1d5 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -187,7 +187,7 @@ class InterfaceTicketEmail extends DolibarrTriggers // Send email to notification email - if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail'])) + if (! empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) { $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; @@ -227,6 +227,8 @@ class InterfaceTicketEmail extends DolibarrTriggers $message_admin = dol_nl2br($message_admin); + $trackid = 'tic'.$object->id; + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; @@ -246,7 +248,7 @@ class InterfaceTicketEmail extends DolibarrTriggers // Send email to customer - if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) + if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) { $sendto = ''; if (empty($user->socid) && empty($user->email)) { @@ -301,12 +303,14 @@ class InterfaceTicketEmail extends DolibarrTriggers $message_customer = dol_nl2br($message_customer); + $trackid = 'tic'.$object->id; + if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); + $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid); if ($mailfile->error) { dol_syslog($mailfile->error, LOG_DEBUG); } else { @@ -317,6 +321,7 @@ class InterfaceTicketEmail extends DolibarrTriggers } } } + $ok = 1; break; diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 6366e93e375..fcb76bd3007 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -87,14 +87,14 @@ TicketEmailNotificationFrom=Notification email from TicketEmailNotificationFromHelp=Used into ticket message answer by example TicketEmailNotificationTo=Notifications email to TicketEmailNotificationToHelp=Send email notifications to this address. -TicketNewEmailBodyLabel=Text message sent after creating a ticket (public interface) +TicketNewEmailBodyLabel=Text message sent after creating a ticket TicketNewEmailBodyHelp=The text specified here will be inserted into the email confirming the creation of a new ticket from the public interface. Information on the consultation of the ticket are automatically added. TicketParamPublicInterface=Public interface setup TicketsEmailMustExist=Require an existing email address to create a ticket TicketsEmailMustExistHelp=In the public interface, the email address should already be filled in the database to create a new ticket. PublicInterface=Public interface -TicketUrlPublicInterfaceLabelAdmin=Public interface URL -TicketUrlPublicInterfaceHelpAdmin=It is possible to define an alias to the web server and thus make available the public interface to another IP address. +TicketUrlPublicInterfaceLabelAdmin=Alternative URL for public interface +TicketUrlPublicInterfaceHelpAdmin=It is possible to define an alias to the web server and thus make available the public interface with another URL (the server must act as a proxy on this new URL) TicketPublicInterfaceTextHomeLabelAdmin=Welcome text of the public interface TicketPublicInterfaceTextHome=You can create a support ticket or view existing from its identifier tracking ticket. TicketPublicInterfaceTextHomeHelpAdmin=The text defined here will appear on the home page of the public interface. @@ -124,7 +124,7 @@ TicketsAutoAssignTicketHelp=When creating a ticket, the user can be automaticall TicketNumberingModules=Tickets numbering module TicketNotifyTiersAtCreation=Notify third party at creation TicketGroup=Group - +TicketsDisableCustomerEmail=Alsways disable emails when a ticket is created from public interface # # Index & list page # @@ -267,7 +267,7 @@ ErrorEmailMustExistToCreateTicket=Error: email address not found in our database TicketNewEmailSubjectAdmin=New ticket created TicketNewEmailBodyAdmin=

Ticket has just been created with ID #%s, see information:

SeeThisTicketIntomanagementInterface=See ticket in management interface -TicketPublicInterfaceForbidden=Access for this area: forbidden +TicketPublicInterfaceForbidden=The public interface for the tickets was not enabled # notifications TicketNotificationEmailSubject=Ticket %s updated diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index ca29f89d39e..5e241c4edfb 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -45,10 +45,11 @@ $langs->loadLangs(array('companies', 'other', 'ticket', 'errors')); $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'alpha'); -/*************************************************** - * VIEW - * - ****************************************************/ + +/* + * View + */ + $form = new Form($db); $formticket = new FormTicket($db); @@ -62,9 +63,9 @@ if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) { print ''; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index ec1e44e9f86..6076cdc4b1b 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1490,52 +1490,6 @@ class Ticket extends CommonObject } } - /** - * Create log for the ticket - * 1- create entry into database for message storage - * 2- if trigger, send an email to ticket contacts - * - * @param User $user User that create - * @param string $message Log message - * @param int $noemail 0=send email after, 1=disable emails - * @return int <0 if KO, >0 if OK - */ - public function createTicketLog(User $user, $message, $noemail = 0) - { - global $conf, $langs; - - $error = 0; - - $this->db->begin(); - - // Clean parameters - $this->message = trim($this->message); - - // Check parameters - if (!$message) { - $this->error = 'ErrorBadValueForParameter'; - return -1; - } - - // TODO Should call the trigger TICKET_MODIFY with $this->context with all data to record event - // so the event is stored by the agenda/event trigger - - if (!$error) { - $this->db->commit(); - - if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { - $this->sendLogByEmail($user, $message); - } - - return 1; - } - else - { - $this->db->rollback(); - - return -1; - } - } /** * Send notification of changes by email diff --git a/htdocs/ticket/css/styles.css.php b/htdocs/ticket/css/styles.css.php index 1f7ed4810a2..a62a4e00a52 100644 --- a/htdocs/ticket/css/styles.css.php +++ b/htdocs/ticket/css/styles.css.php @@ -68,14 +68,17 @@ div.ticketform { border-radius: 10px 10px 10px 10px; margin: 1.5em; background : #ffffff; - - + text-align: center; } div.ticketform .index_create, .index_display { - float: left; - width: 33%; + display: inline-block; + width: 200px; + height: 58px; text-align: center; + vertical-align: middle; + margin: 20px; + text-transform: uppercase; } div.ticketform .orange { From ff9b6c2f04e644b1fda5a941bcae1b066e37f627 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 19:19:20 +0100 Subject: [PATCH 15/99] Module ticket --- htdocs/admin/ticket_public.php | 453 +++++++++++++++++++++++++++++++++ 1 file changed, 453 insertions(+) create mode 100644 htdocs/admin/ticket_public.php diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php new file mode 100644 index 00000000000..939a357999b --- /dev/null +++ b/htdocs/admin/ticket_public.php @@ -0,0 +1,453 @@ + + * Copyright (C) 2016 Christophe Battarel + * + * 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 admin/ticket_public.php + * \ingroup ticket + * \brief Page to public interface of module Ticket + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; + +// Load translation files required by the page +$langs->loadLangs(array("admin", "ticket")); + +// Access control +if (!$user->admin) { + accessforbidden(); +} + +// Parameters +$value = GETPOST('value', 'alpha'); +$action = GETPOST('action', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scandir', 'alpha'); +$type = 'ticket'; + +if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') +{ + if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); +} + +if ($action == 'setvar') { + include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; + + $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); + if (!empty($notification_email)) { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + // altairis : differentiate notification email FROM and TO + $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha'); + if (!empty($notification_email_to)) { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); + if (!empty($mail_new_ticket)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); + if (!empty($mail_intro)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); + if (!empty($text_help)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } +} + +if ($action == 'setvarother') { + $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } + + $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } +} + + + +/* + * View + */ + +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + +$form = new Form($db); + +$help_url = "FR:Module_Ticket"; +$page_name = "TicketSetup"; +llxHeader('', $langs->trans($page_name), $help_url); + +// Subheader +$linkback = '' . $langs->trans("BackToModuleList") . ''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + +// Configuration header +$head = ticketAdminPrepareHead(); + +dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); + +print ''.$langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; + +dol_fiche_end(); + + +$enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; +if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +{ + // Button off, click to enable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml.=''; +} +else +{ + // Button on, click to disable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml.=''; +} +print $enabledisablehtml; +print ''; + +print '

'; + +if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +{ + + if (!$conf->use_javascript_ajax) { + print '
'; + print ''; + print ''; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + // Check if email exists + print ''; + print ''; + print ''; + print ''; + + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + // Show logo for module + print ''; + print ''; + print ''; + print ''; + }*/ + + // Show logo for company + print ''; + print ''; + print ''; + print ''; + + // Also send to main email address + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + print ''; + print ''; + print ''; + print ''; + } + + if (!$conf->use_javascript_ajax) { + print ''; + print ''; + } + + // Auto assign ticket at user who created it + print ''; + print ''; + print ''; + print ''; + + print '
' . $langs->trans("Parameters") . ''; + print ''; + print '
' . $langs->trans("TicketsEmailMustExist") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowModuleLogo") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowCompanyLogo") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsAutoAssignTicket") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help'); + print '

'; + + if (!$conf->use_javascript_ajax) { + print '
'; + } + + // Admin var of module + print load_fiche_titre($langs->trans("TicketParamMail")); + + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print "\n"; + + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { + print ''; + print ''; + print "\n"; + } + + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print ''; + print ''; + print ''; + + // Interface topic + $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; + print ''; + print ''; + print ''; + + // Texte d'accueil homepage + $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); + print ''; + print ''; + + // Texte d'aide à la saisie du message + $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); + print ''; + print ''; + + // Activate email creation to user + print ''; + print ''; + print ''; + print ''; + + // Texte de création d'un ticket + $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); + print ''; + print ''; + + print '
' . $langs->trans("Parameter") . '
' . $langs->trans("TicketCkEditorEmailNotActivated") . '
' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketsDisableCustomerEmail") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); + print '
' . $langs->trans("TicketNewEmailBodyLabel") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); + print '
'; + + print '
'; + + print ''; +} + +// End of page +llxFooter(); +$db->close(); From 1d6028dfb0dbc32eaca88318045a65d244ecef22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 19:38:52 +0100 Subject: [PATCH 16/99] FIX PHPUnit --- .../stock/class/mouvementstock.class.php | 37 +++++++++++-------- test/phpunit/MouvementStockTest.php | 12 +++--- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 39a9bb94bed..bf267c9985e 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -88,7 +88,7 @@ class MouvementStock extends CommonObject $this->db = $db; } - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Add a movement of stock (in one direction only) * @@ -111,9 +111,10 @@ class MouvementStock extends CommonObject * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) * @return int <0 if KO, 0 if fk_product is null, >0 if OK */ - private function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) + public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) { - global $conf, $langs; + // phpcs:disable + global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; @@ -724,20 +725,26 @@ class MouvementStock extends CommonObject /** * Increase stock for product and subproducts * - * @param User $user Object user - * @param int $fk_product Id product - * @param int $entrepot_id Warehouse id - * @param int $qty Quantity - * @param int $price Price - * @param string $label Label of stock movement - * @param date $eatby eat-by date - * @param date $sellby sell-by date - * @param string $batch batch number - * @return int <0 if KO, >0 if OK + * @param User $user Object user + * @param int $fk_product Id product + * @param int $entrepot_id Warehouse id + * @param int $qty Quantity + * @param int $price Price + * @param string $label Label of stock movement + * @param date $eatby eat-by date + * @param date $sellby sell-by date + * @param string $batch batch number + * @param string $datem Force date of movement + * @param int $id_product_batch Id product_batch + * @return int <0 if KO, >0 if OK */ - public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '') + public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0) { - return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, '', '', $eatby, $sellby, $batch); + global $conf; + + $skip_batch = empty($conf->productbatch->enabled); + + return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, '', $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); } diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index cedd5b4741c..597f4b88de6 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -163,17 +163,17 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase // Do a list of movement into warehouse 1 // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 - $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); + $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); + $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test'); + $result=$localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3', 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); @@ -191,17 +191,17 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase // Do same but into warehouse 2 // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 - $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); + $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); + $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); + $result=$localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); From f283782445093a5fc46a7d6dd18847673dd7003a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 19:57:46 +0100 Subject: [PATCH 17/99] change visibility --- htdocs/adherents/class/api_members.class.php | 5 +++-- .../adherents/class/api_memberstypes.class.php | 5 +++-- htdocs/api/class/api_documents.class.php | 17 +++++++++-------- htdocs/api/class/api_setup.class.php | 4 +++- htdocs/bom/class/api_bom.class.php | 4 +++- .../categories/class/api_categories.class.php | 5 +++-- .../action/class/api_agendaevents.class.php | 5 +++-- .../comm/propal/class/api_proposals.class.php | 5 +++-- htdocs/commande/class/api_orders.class.php | 5 +++-- .../bank/class/api_bankaccounts.class.php | 4 +++- .../compta/facture/class/api_invoices.class.php | 5 +++-- htdocs/contrat/class/api_contracts.class.php | 5 +++-- htdocs/don/class/api_donations.class.php | 5 +++-- htdocs/expedition/class/api_shipments.class.php | 5 +++-- .../class/api_expensereports.class.php | 5 +++-- .../fichinter/class/api_interventions.class.php | 5 +++-- .../fourn/class/api_supplier_invoices.class.php | 5 +++-- .../fourn/class/api_supplier_orders.class.php | 5 +++-- .../template/class/api_mymodule.class.php | 4 +++- htdocs/product/class/api_products.class.php | 5 +++-- .../stock/class/api_stockmovements.class.php | 5 +++-- .../stock/class/api_warehouses.class.php | 5 +++-- htdocs/projet/class/api_projects.class.php | 5 +++-- htdocs/projet/class/api_tasks.class.php | 5 +++-- htdocs/societe/class/api_contacts.class.php | 5 +++-- htdocs/societe/class/api_thirdparties.class.php | 4 +++- .../class/api_supplier_proposals.class.php | 5 +++-- htdocs/ticket/class/api_tickets.class.php | 6 +++--- htdocs/user/class/api_users.class.php | 4 +++- 29 files changed, 93 insertions(+), 59 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 6025f2a2985..6948bce1e25 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -288,15 +288,16 @@ class Members extends DolibarrApi return $member; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Remove the subscriptions because they are handled as a subresource. diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 43fd2635fb4..abfaf84993d 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -266,15 +266,16 @@ class MembersTypes extends DolibarrApi return $membertype; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->array_options); diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 19bd61c641b..f4a7084b336 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -274,7 +274,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; } - else if ($modulepart == 'adherent' || $modulepart == 'member') + elseif ($modulepart == 'adherent' || $modulepart == 'member') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -290,7 +290,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); } - else if ($modulepart == 'propal' || $modulepart == 'proposal') + elseif ($modulepart == 'propal' || $modulepart == 'proposal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; @@ -306,7 +306,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); } - else if ($modulepart == 'commande' || $modulepart == 'order') + elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -322,7 +322,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande'); } - else if ($modulepart == 'shipment' || $modulepart == 'expedition') + elseif ($modulepart == 'shipment' || $modulepart == 'expedition') { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; @@ -338,7 +338,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment'); } - else if ($modulepart == 'facture' || $modulepart == 'invoice') + elseif ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -354,7 +354,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); } - else if ($modulepart == 'produit' || $modulepart == 'product') + elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -370,7 +370,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->product->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'product'); } - else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') + elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -600,7 +600,8 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - private function _validate_file($data) { + private function _validate_file($data) + { // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 766cf79f7be..783ec6540e3 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -273,14 +273,16 @@ class Setup extends DolibarrApi return $list; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->error); diff --git a/htdocs/bom/class/api_bom.class.php b/htdocs/bom/class/api_bom.class.php index 4bb4f1a96ab..4d13475be1a 100644 --- a/htdocs/bom/class/api_bom.class.php +++ b/htdocs/bom/class/api_bom.class.php @@ -283,14 +283,16 @@ class BillOfMaterialsApi extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); /*unset($object->note); diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 434b7ba1d24..c975236f930 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -261,15 +261,16 @@ class Categories extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param Categorie $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Remove fields not relevent to categories diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index b6df9ec7d96..ec899d72ae1 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -313,15 +313,16 @@ class AgendaEvents extends DolibarrApi return $event; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->usermod); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 33122986187..9145b8eb151 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -782,15 +782,16 @@ class Proposals extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->note); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2bd942a3c34..24508d6fb11 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -838,15 +838,16 @@ class Orders extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->note); diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 04692fb4e44..72ba4c82db1 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -248,14 +248,16 @@ class BankAccounts extends DolibarrApi return $account; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->rowid); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 6c4c94fc2ce..d68c3d40338 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1417,15 +1417,16 @@ class Invoices extends DolibarrApi return $paiement_id; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->note); diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 6f4a2041670..00d168a0db4 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -633,15 +633,16 @@ class Contracts extends DolibarrApi + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->address); diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 06ddd5616c0..8762f763da7 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -326,15 +326,16 @@ class Donations extends DolibarrApi return $this->_cleanObjectDatas($this->don); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->note); diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 73923105c7d..0c8f8717aea 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -610,15 +610,16 @@ class Shipments extends DolibarrApi } */ + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->thirdparty); // id already returned diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 35ce9f9a4a2..cb5a438bc21 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -489,15 +489,16 @@ class ExpenseReports extends DolibarrApi ); }*/ + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->barcode_type); diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index d49f58ed52e..2702ad6c55e 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -417,15 +417,16 @@ class Interventions extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->statuts_short); diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 3f94401bc9d..416f7e11e94 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -333,15 +333,16 @@ class SupplierInvoices extends DolibarrApi ); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param Object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->rowid); diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 9a898fae3a7..42f7eccf608 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -330,15 +330,16 @@ class SupplierOrders extends DolibarrApi ); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param Object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->rowid); diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index cdb5a4b74f4..566fe56affb 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -280,14 +280,16 @@ class MyModuleApi extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); /*unset($object->note); diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c95bcdcb8f4..756bbde5b29 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -468,15 +468,16 @@ class Products extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->regeximgext); diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 4c5971b8cc4..12cf15110fe 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -274,15 +274,16 @@ class StockMovements extends DolibarrApi + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param MouvementStock $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Remove useless data diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index 18286cea931..e0a05af4226 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -243,15 +243,16 @@ class Warehouses extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param Entrepot $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Remove the subscriptions because they are handled as a subresource. diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 532f46ccfe4..9680cd66591 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -534,15 +534,16 @@ class Projects extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->titre); diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 40c3e78f7e6..9fafcb98343 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -547,15 +547,16 @@ class Tasks extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->barcode_type); diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 97fc83a3545..772d8d3fe10 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -379,15 +379,16 @@ class Contacts extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param Object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->total_ht); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 3cc1dd51b1a..954535d1c87 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1626,14 +1626,16 @@ $reshook = $hookmanager->executeHooks('replaceThirdparty', array( } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->nom); // ->name already defined and nom deprecated diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 15f4278bf49..5ac77fe85bb 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -190,15 +190,16 @@ class Supplierproposals extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->name); diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 005d8084f31..fedadd2c96e 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -513,7 +513,7 @@ class Tickets extends DolibarrApi return $ticket; } - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * @@ -523,9 +523,9 @@ class Tickets extends DolibarrApi * @todo use an array for properties to clean * */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Other attributes to clean diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 625fd913f5e..17e22a314ef 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -354,14 +354,16 @@ class Users extends DolibarrApi return $this->useraccount->delete(DolibarrApiAccess::$user); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable global $conf; $object = parent::_cleanObjectDatas($object); From 15138aa543e63d5083d9b2e4fbb250bca56bb891 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 20:00:36 +0100 Subject: [PATCH 18/99] FIX error on setup of password if pass generators have a .old file. --- htdocs/admin/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 26dcdc85b8d..291a2948987 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -212,7 +212,7 @@ if (is_resource($handle)) { while (($file = readdir($handle))!==false) { - if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg)) + if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i',$file,$reg)) { // Charging the numbering class $classname = $reg[1]; From 54b9681257171e9c15215290f71295bb09384344 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 20:15:31 +0100 Subject: [PATCH 19/99] More log to help debug --- htdocs/core/login/functions_dolibarr.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 25d5f2dc30c..eede3bf2ee6 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -80,7 +80,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED; // By default, we used MD5 - if (! in_array($cryptType,array('md5'))) $cryptType='md5'; + if (! in_array($cryptType, array('md5'))) $cryptType='md5'; // Check crypted password according to crypt algorithm if ($cryptType == 'md5') { @@ -109,8 +109,9 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."'"); - sleep(2); // Anti brut force protection + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."', cryptType=".$cryptType); + //dol_syslog("passclear=".$passclear." passtyped=".$passtyped." passcrypted=".$passcrypted); + sleep(2); // Anti brut force protection $langs->load('main'); $langs->load('errors'); $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); From 16c73af0cb131d3860f6945a61619a15c2a99f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 20:16:18 +0100 Subject: [PATCH 20/99] remove test ticketlog --- test/phpunit/TicketTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/TicketTest.php b/test/phpunit/TicketTest.php index 175ced68bda..b5bfd9212e9 100644 --- a/test/phpunit/TicketTest.php +++ b/test/phpunit/TicketTest.php @@ -341,7 +341,7 @@ class TicketTest extends PHPUnit_Framework_TestCase * @depends testTicketFetch * The depends says test is run only if previous is ok */ - public function testTicketcreateTicketLog($localobject) + /*public function testTicketcreateTicketLog($localobject) { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -357,7 +357,7 @@ class TicketTest extends PHPUnit_Framework_TestCase $this->assertGreaterThan(0, $result); return $localobject; - } + }*/ /** * testTicketclose From e974a3b2b37a949ed39e94e99cd2491d66dece4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 20:36:05 +0100 Subject: [PATCH 21/99] Add more info --- htdocs/admin/security.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 4af3854d6b9..b5c4dd8dc9d 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -398,7 +398,6 @@ print ''.$langs->trans("Action").''; print ''; // Disable clear password in database - print ''; print ''.$langs->trans("DoNotStoreClearPassword").''; print ''; @@ -413,6 +412,8 @@ if (! $conf->global->DATABASE_PWD_ENCRYPTED) print ''.$langs->trans("Activate").''; print ""; } + +// Database conf file encryption if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) { print ''; @@ -494,9 +495,21 @@ print ''; print ''; print ''; +print '
'; - -//print ''; +if (GETPOST('info','int') > 0) +{ + if (function_exists('password_hash')) + { + print $langs->trans("Note: The function password_hash exists on your PHP"); + } + else + { + print $langs->trans("Note: The function password_hash does not exists on your PHP"); + } + print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; + print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; +} print ''; From b7066d92ccc046cf2c5128e6c8a65c2cf31cf12c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 20:37:03 +0100 Subject: [PATCH 22/99] More info --- htdocs/admin/security.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index b5c4dd8dc9d..6c3ed1f294b 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -501,11 +501,11 @@ if (GETPOST('info','int') > 0) { if (function_exists('password_hash')) { - print $langs->trans("Note: The function password_hash exists on your PHP"); + print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; } else { - print $langs->trans("Note: The function password_hash does not exists on your PHP"); + print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; } print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; From 2f3c3aeb05e2cc649884cda8cb5c2d6eb4ff5c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 21:24:48 +0100 Subject: [PATCH 23/99] test --- test/phpunit/MouvementStockTest.php | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index 597f4b88de6..b6acdfd11b1 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -162,27 +162,27 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase // Do a list of movement into warehouse 1 - // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 - $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); + // Create an input movement (type = 3) of price 9.9 -> should update PMP to 9.9 + $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); + // Create an input movement (type = 3) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 + $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3', 'Inventory Code Test'); + // Create an output movement (type = 2) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 + $result=$localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 + // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 + // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); @@ -190,27 +190,27 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase // Do same but into warehouse 2 - // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 - $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); + // Create an input movement (type = 3) of price 9.9 -> should update PMP to 9.9 + $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); + // Create an input movement (type = 3) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 + $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); + // Create an output movement (type = 2) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 + $result=$localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 + // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 + // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); From e8b21887e2f186659cf75f2dfd49b48a908617b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 21:41:00 +0100 Subject: [PATCH 24/99] phpcs --- htdocs/admin/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 6c3ed1f294b..df2d2b09ee6 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -497,7 +497,7 @@ print ''; print ''; print '
'; -if (GETPOST('info','int') > 0) +if (GETPOST('info', 'int') > 0) { if (function_exists('password_hash')) { From 023992f2e14758743265bc7d1a34753a11318db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 23:06:23 +0100 Subject: [PATCH 25/99] Update list.php --- htdocs/ticket/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 0b3a1c101e8..3a0e8fea9d6 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -580,7 +580,7 @@ foreach($object->fields as $key => $val) if ($key == 'fk_statut') $cssforfield.=($cssforfield?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, '', $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; } } // Extra fields From 162f2614e5527d9d0aaadb728bc90e171264a8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 23:25:23 +0100 Subject: [PATCH 26/99] Update mymodulewidget1.php --- htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 7416eb1c35e..087f102daef 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -186,7 +186,7 @@ class mymodulewidget1 extends ModeleBoxes 'tr' => 'class="left"', 'text' => '' ), - 0 => array( // TR + 1 => array( // TR 'tr' => 'class="left"', 'text' => '' ) From 784012a47e9384eb8ec1c0d61b1e21d5df3154b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Mar 2019 23:47:40 +0100 Subject: [PATCH 27/99] Update main.inc.php --- htdocs/main.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 70571964162..4a85cd8ddab 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -395,6 +395,7 @@ if ((! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf-> { dol_syslog("Invalid token, so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. + if ($conf->global->MAIN_FEATURES_LEVEL>1) setEventMessages('Unset POST by CSRF protection in main.inc.php.', null, 'warnings'); unset($_POST); unset($_GET['confirm']); } From 5cf8421d87d76853a977e20566fb14ddd193a7a5 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Tue, 5 Mar 2019 09:56:49 +0100 Subject: [PATCH 28/99] Fix remove "canceled" invoices in all reports --- htdocs/margin/checkMargins.php | 3 ++- htdocs/margin/customerMargins.php | 4 +++- htdocs/margin/productMargins.php | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index d418aba780e..a05762b4bb5 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -183,6 +183,7 @@ dol_fiche_end(); $arrayfields=array(); $massactionbutton=''; +$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); $sql = "SELECT"; $sql .= " f.ref, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty"; @@ -190,7 +191,7 @@ $sql .= " ,d.fk_product"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as d ON d.fk_facture = f.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid"; -$sql .= " WHERE f.fk_statut > 0"; +$sql .= " WHERE f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")"; $sql .= " AND f.entity IN (" . getEntity('invoice') . ") "; if (! empty($startdate)) $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'"; if (! empty($enddate)) $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'"; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index fa264a81920..cc5abb0ee38 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -200,6 +200,8 @@ dol_fiche_end(); print ''; +$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); + $sql = "SELECT"; $sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; if ($client) $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; @@ -218,7 +220,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PRE $sql.= " WHERE f.fk_soc = s.rowid"; if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " AND f.fk_statut > 0"; +$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")"; $sql.= ' AND s.entity IN ('.getEntity('societe').')'; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 95686967fd9..547bd3d205b 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -174,6 +174,8 @@ dol_fiche_end(); print ''; +$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); + $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; if ($id > 0) $sql.= " d.fk_product,"; if ($id > 0) $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; @@ -190,7 +192,7 @@ if (! empty($TSelectedCats)) { } $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= ' AND f.entity IN ('.getEntity('invoice').')'; -$sql.= " AND f.fk_statut > 0"; +$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")"; $sql.= " AND d.fk_facture = f.rowid"; if ($id > 0) $sql.= " AND d.fk_product =".$id; From ef10a3206906707ec88bf36b3c493a593c2a0a4f Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Tue, 5 Mar 2019 11:18:44 +0100 Subject: [PATCH 29/99] Fix authorize long references in Beluga PDF model (uses Landscape mode) --- .../project/doc/pdf_beluga.modules.php | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index f24f400f2af..95bba01ad23 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -54,6 +54,12 @@ if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/com class pdf_beluga extends ModelePDFProjects { + /** + * Page orientation + * @var string 'P' or 'Portait' (default), 'L' or 'Landscape' + */ + private $orientation = ''; + /** * Issuer * @var Societe @@ -79,8 +85,14 @@ class pdf_beluga extends ModelePDFProjects // Dimension page pour format A4 $this->type = 'pdf'; $formatarray=pdf_getFormat(); - $this->page_largeur = $formatarray['width']; - $this->page_hauteur = $formatarray['height']; + $this->orientation = 'L'; + if ($this->orientation == 'L' || $this->orientation == 'Landscape') { + $this->page_largeur = $formatarray['height']; + $this->page_hauteur = $formatarray['width']; + } else { + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + } $this->format = array($this->page_largeur,$this->page_hauteur); $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; @@ -95,13 +107,22 @@ class pdf_beluga extends ModelePDFProjects $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Defini position des colonnes - $this->posxref=$this->marge_gauche+1; - $this->posxdate=$this->marge_gauche+25; - $this->posxsociety=$this->marge_gauche+45; - $this->posxamountht=$this->marge_gauche+110; - $this->posxamountttc=$this->marge_gauche+135; - $this->posxstatut=$this->marge_gauche+165; + // Defini position des colonnes + if ($this->orientation == 'L' || $this->orientation == 'Landscape') { + $this->posxref=$this->marge_gauche+1; + $this->posxdate=$this->marge_gauche+105; + $this->posxsociety=$this->marge_gauche+125; + $this->posxamountht=$this->marge_gauche+190; + $this->posxamountttc=$this->marge_gauche+215; + $this->posxstatut=$this->marge_gauche+245; + } else { + $this->posxref=$this->marge_gauche+1; + $this->posxdate=$this->marge_gauche+25; + $this->posxsociety=$this->marge_gauche+45; + $this->posxamountht=$this->marge_gauche+110; + $this->posxamountttc=$this->marge_gauche+135; + $this->posxstatut=$this->marge_gauche+165; + } if ($this->page_largeur < 210) // To work with US executive format { $this->posxref-=20; @@ -217,7 +238,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page - $pdf->AddPage(); + $pdf->AddPage($this->orientation); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); @@ -433,7 +454,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); // Description of line @@ -469,7 +490,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->rollbackTransaction(true); $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. // Label $pdf->SetXY($this->posxref, $curY); $posybefore=$pdf->GetY(); @@ -480,7 +501,7 @@ class pdf_beluga extends ModelePDFProjects { if ($i == ($num-1)) // No more lines, and no space left to show total, so we create a new page { - $pdf->AddPage('', '', true); + $pdf->AddPage($this->orientation, '', true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pageposafter+1); @@ -495,9 +516,9 @@ class pdf_beluga extends ModelePDFProjects { $pdf->rollbackTransaction(true); $pageposafter=$pageposbefore; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $pdf->AddPage('', '', true); + $pdf->AddPage($this->orientation, '', true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pageposafter+1); @@ -505,7 +526,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $curY = $tab_top_newpage + $heightoftitleline + 1; // Label @@ -528,7 +549,7 @@ class pdf_beluga extends ModelePDFProjects $pageposafter=$pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { @@ -628,7 +649,7 @@ class pdf_beluga extends ModelePDFProjects $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } From b851911708664fc82eb503e3eda3316879003987 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 12:18:36 +0100 Subject: [PATCH 30/99] Dolibarize module ticket --- htdocs/comm/action/card.php | 12 +-- htdocs/comm/action/document.php | 4 +- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/core/class/html.formticket.class.php | 55 ++++++----- htdocs/core/modules/modTicket.class.php | 2 +- ...terface_50_modAgenda_ActionsAuto.class.php | 2 - ...terface_50_modTicket_TicketEmail.class.php | 4 - htdocs/langs/en_US/ticket.lang | 14 +-- htdocs/resource/element_resource.php | 2 +- htdocs/ticket/card.php | 47 ++++++--- htdocs/ticket/class/actions_ticket.class.php | 90 ++++++++--------- htdocs/ticket/class/ticket.class.php | 9 +- htdocs/ticket/list.php | 14 +-- htdocs/ticket/new.php | 96 ------------------- 14 files changed, 137 insertions(+), 216 deletions(-) delete mode 100644 htdocs/ticket/new.php diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b542cf4dd67..8458207a5d8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -682,7 +682,7 @@ if ($action == 'create') dol_fiche_head(); - print ''; + print '
'; // Type of event if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) @@ -849,7 +849,7 @@ if ($action == 'create') print '


'; - print '
'; + print '
'; if ($conf->societe->enabled) { @@ -1078,7 +1078,7 @@ if ($id > 0) dol_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action'); - print '
'; + print '
'; // Ref print ''; @@ -1259,7 +1259,7 @@ if ($id > 0) print '


'; - print '
'.$langs->trans("Ref").''.$object->id.'
'; + print '
'; if ($conf->societe->enabled) { @@ -1455,7 +1455,7 @@ if ($id > 0) print '
'; // Affichage fiche action en mode visu - print '
'; + print '
'; // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) @@ -1558,7 +1558,7 @@ if ($id > 0) print '
'; print '
'; - print '
'; + print '
'; if ($conf->societe->enabled) { diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 04b63966fd2..7eec20c3499 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -166,7 +166,7 @@ if ($object->id > 0) print '
'; // Affichage fiche action en mode visu - print '
'; + print '
'; // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) @@ -237,7 +237,7 @@ if ($object->id > 0) print '
'; - print ''; + print '
'; // Build file list $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9ef1098901c..b4c0c4295c9 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -60,7 +60,7 @@ class FormProjets * @param int $maxlength Maximum length of label * @param int $option_only Return only html options lines without the select tag * @param int $show_empty Add an empty line - * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) + * @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable) * @param int $forcefocus Force focus on field (works with javascript only) * @param int $disabled Disabled * @param int $mode 0 for HTML mode and 1 for JSON mode diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index cdbf35dc32b..c255145ee58 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -24,6 +24,7 @@ */ require_once DOL_DOCUMENT_ROOT . "/core/class/html.form.class.php"; require_once DOL_DOCUMENT_ROOT . "/core/class/html.formmail.class.php"; +require_once DOL_DOCUMENT_ROOT . "/core/class/html.formprojet.class.php"; if (!class_exists('FormCompany')) { include DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; @@ -103,7 +104,7 @@ class FormTicket { $this->db = $db; - $this->action = 'add_ticket'; + $this->action = 'add'; $this->withcompany = 1; $this->withfromsocid = 0; @@ -258,6 +259,14 @@ class FormTicket print ''; print ''; } + + // Notify thirdparty at creation + if (empty($this->ispublic)) + { + print ''; + } } // TITLE @@ -305,14 +314,6 @@ class FormTicket $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); print ''; - // Notify thirdparty at creation - if (empty($this->ispublic)) - { - print ''; - } - // TITLE if ($this->withtitletopic) { print ''; + if (! empty($conf->projet->enabled) && ! $this->ispublic) + { + $formproject=new FormProjets($this->db); + print ''; + } + // Attached files if (!empty($this->withfile)) { // Define list of attached files @@ -408,7 +420,7 @@ class FormTicket if ($withdolfichehead) dol_fiche_end(); print '
'; - print ''; + print ''; if ($this->withcancel) { print "     "; @@ -724,7 +736,7 @@ class FormTicket /** * Show the form to add message on ticket * - * @param string $width Width of form + * @param string $width Width of form * @return void */ public function showMessageForm($width = '40%') @@ -818,7 +830,6 @@ class FormTicket print '
'; + print 'withnotifytiersatcreate?' checked="checked"':'').'>'; + print '
'; - print 'withnotifytiersatcreate?' checked="checked"':'').'>'; - print '
'; @@ -331,19 +332,30 @@ class FormTicket } // MESSAGE - $msg = GETPOST('message', 'alpha') ? GETPOST('message', 'alpha') : ''; + $msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : ''; print '
'; // If public form, display more information - if ($this->ispublic) { + $toolbarname = 'dolibarr_notes'; + if ($this->ispublic) + { + $toolbarname = 'dolibarr_details'; print '
' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '
'; } include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $uselocalbrowser = true; - $doleditor = new DolEditor('message', GETPOST('message', 'alpha'), '100%', 230, 'dolibarr_details', 'In', true, $uselocalbrowser); + $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser); $doleditor->Create(); print '
'; + print $formproject->select_projects(-1, GETPOST('projectid','int'), 'projectid', 0, 0, 1, 1); + print '
'; - // External users can't send message email if ($user->rights->ticket->write && !$user->socid) { print '
'; @@ -952,9 +963,11 @@ class FormTicket $defaultmessage=preg_replace("/^\n+/", "", $defaultmessage); } - print '
'; + print '
'; + //$toolbarname = 'dolibarr_details'; + $toolbarname = 'dolibarr_notes'; include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor('message', $defaultmessage, '100%', 350, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, 70); $doleditor->Create(); print ''; if ($user->rights->ticket->write && !$user->socid) { @@ -1014,17 +1027,15 @@ class FormTicket print $out; } - print '
'; - print '
'; - print ''; + print '
'; + print '

'; + print ''; if ($this->withcancel) { print "     "; print "trans("Cancel") . "\">"; } print "
\n"; - print ''; - print ''; print "\n"; print "\n"; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 0ca3b3c99be..3c1c6c43068 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -218,7 +218,7 @@ class modTicket extends DolibarrModules 'type' => 'left', 'titre' => 'NewTicket', 'mainmenu' => 'ticket', - 'url' => '/ticket/new.php?action=create_ticket', + 'url' => '/ticket/card.php?action=create', 'langs' => 'ticket', 'position' => 102, 'enabled' => '$conf->ticket->enabled', diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 15e2974247e..095cd59ff55 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -761,7 +761,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } - elseif($action == 'TASK_MODIFY') { // Load translation files required by the page @@ -773,7 +772,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } - elseif($action == 'TASK_DELETE') { // Load translation files required by the page diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 12baad3b1d5..c484ba7c6d4 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -333,10 +333,6 @@ class InterfaceTicketEmail extends DolibarrTriggers dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); break; - case 'TICKET_MARK_READ': - dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - break; - case 'TICKET_CLOSE': dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); break; diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index fcb76bd3007..3759a9c881b 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -154,7 +154,6 @@ TicketMarkedAsRead=Ticket has been marked as read TicketReadOn=Read on TicketCloseOn=Clotured on MarkAsRead=Mark ticket as read -TicketMarkedAsReadButLogActionNotSaved=Ticket marked as closed but no action saved TicketHistory=Ticket history AssignUser=Assign to user TicketAssigned=Ticket is now assigned @@ -179,7 +178,6 @@ ConfirmCloseAticket=Confirm ticket closing ConfirmDeleteTicket=Please confirm ticket deleting TicketDeletedSuccess=Ticket deleted with success TicketMarkedAsClosed=Ticket marked as closed -TicketMarkedAsClosedButLogActionNotSaved=Ticket marked as closed but no log saved ! TicketDurationAuto=Calculated duration TicketDurationAutoInfos=Duration calculated automatically from intervention related TicketUpdated=Ticket updated @@ -226,14 +224,12 @@ Unread=Unread # # Logs # -TicketLogMesgReadBy=Ticket read by %s +TicketLogMesgReadBy=Ticket %s read by %s NoLogForThisTicket=No log for this ticket yet -TicketLogAssignedTo=Ticket assigned to %s -TicketAssignedButLogActionNotSaved=Ticket assigned but no log saved ! -TicketLogPropertyChanged=Change classification: from %s to %s -TicketLogClosedBy=Ticket closed by %s -TicketLogProgressSetTo=Progress change to %s percent -TicketLogReopen=Ticket re-opened +TicketLogAssignedTo=Ticket %s assigned to %s +TicketLogPropertyChanged=Ticket %s modified: classification from %s to %s +TicketLogClosedBy=Ticket %s closed by %s +TicketLogReopen=Ticket %s re-opened # # Public pages diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 13d61bc17ac..bba4d329c24 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -238,7 +238,7 @@ else print '
'; - print ''; + print '
'; // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index c71a2211e7f..fd434ef395f 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -49,8 +49,11 @@ $id = GETPOST('id', 'int'); $track_id = GETPOST('track_id', 'alpha', 3); $ref = GETPOST('ref', 'alpha'); $projectid = GETPOST('projectid', 'int'); +$cancel = GETPOST('cancel', 'alpha'); $action = GETPOST('action', 'aZ09'); +$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); + // Initialize technical object to manage hooks of ticket. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ticketcard','globalcard')); @@ -155,10 +158,8 @@ if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') & $ret = $object->update($user); if ($ret > 0) { $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); - } + + setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); } $action = 'view'; } @@ -183,6 +184,28 @@ $page_title = $actionobject->getTitle($action); llxHeader('', $page_title, $help_url); +if ($action == 'create') +{ + $formticket = new FormTicket($db); + + print load_fiche_titre($langs->trans('NewTicket'), '', 'title_ticket'); + + $formticket->withfromsocid = $socid ? $socid : $user->societe_id; + $formticket->withfromcontactid = $contactid ? $contactid : ''; + $formticket->withtitletopic = 1; + $formticket->withnotifytiersatcreate = ($notifyTiers?1:0); + $formticket->withusercreate = 1; + $formticket->withref = 1; + $formticket->fk_user_create = $user->id; + $formticket->withfile = 2; + $formticket->withextrafields = 1; + $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid')); + if (empty($defaultref)) { + $defaultref = ''; + } + + $formticket->showForm(1); +} if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') @@ -721,7 +744,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd if (empty($reshook)) { // Show link to add a message (if read and not closed) - if ($object->fk_statut < 8 && $action != "add_message") { + if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "add_message") { print ''; } @@ -730,22 +753,22 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd if (!$object->fk_soc && $user->rights->ficheinter->creer) { print ''; } - if ($object->fk_soc > 0 && $object->fk_statut < 8 && $user->rights->ficheinter->creer) { + if ($object->fk_soc > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ficheinter->creer) { print ''; } // Close ticket if statut is read - if ($object->fk_statut > 0 && $object->fk_statut < 8 && $user->rights->ticket->write) { + if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) { print ''; } // Re-open ticket - if (!$user->socid && $object->fk_statut == 8 && !$user->societe_id) { + if (!$user->socid && $object->fk_statut == Ticket::STATUS_CLOSED && !$user->societe_id) { print ''; } // Delete ticket - if ($user->rights->ticket->delete && !$user->societe_id) { + if ($user->rights->ticket->delete && ! $user->societe_id) { print ''; } } @@ -758,7 +781,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $action = 'presend'; } - if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'edit_message_init') + if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'delete' || $action == 'edit_message_init') { print '
'; print ''; // ancre @@ -786,6 +809,8 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print '
'; print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket'); + print '
'; + // Define output language $outputlangs = $langs; $newlang = ''; @@ -803,6 +828,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $formticket->id = $object->id; $formticket->withfile = 2; + $formticket->withcancel = 1; $formticket->param = array('fk_user_create' => $user->id); $formticket->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); @@ -839,7 +865,6 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $formticket->substit['__TICKETSUP_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); } - $formticket->showMessageForm('100%'); print '
'; } diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 395ab2078c7..39d51017c41 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -133,7 +133,7 @@ class ActionsTicket dol_mkdir($upload_dir_tmp); } dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '-__file__'); - $action = !empty($object->track_id) ? 'add_message' : 'create_ticket'; + $action = !empty($object->track_id) ? 'add_message' : 'create'; ////} } @@ -156,21 +156,21 @@ class ActionsTicket // TODO Delete only files that was uploaded from email form dol_remove_file_process($_POST['removedfile'], 0); - $action = !empty($object->track_id) ? 'add_message' : 'create_ticket'; + $action = !empty($object->track_id) ? 'add_message' : 'create'; ////} } - if (GETPOST('add_ticket') && $user->rights->ticket->write) { + if (GETPOST('add','alpha') && $user->rights->ticket->write) { $error = 0; if (!GETPOST("subject")) { $error++; $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); - $action = 'create_ticket'; + $action = 'create'; } elseif (!GETPOST("message")) { $error++; $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("message")); - $action = 'create_ticket'; + $action = 'create'; } if (!$error) { @@ -189,6 +189,8 @@ class ActionsTicket $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1; + $object->fk_project = GETPOST('projectid', 'int'); + $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -198,7 +200,7 @@ class ActionsTicket $error++; $this->error = $object->error; $this->errors = $object->errors; - $action = 'create_ticket'; + $action = 'create'; } if (!$error && $id > 0) @@ -338,19 +340,15 @@ class ActionsTicket if ($action == "mark_ticket_read" && $user->rights->ticket->write) { $object->fetch('', '', GETPOST("track_id", 'alpha')); - if ($object->markAsRead($user) > 0) { - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogMesgReadBy', $user->getFullName($langs)); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); - } else { - setEventMessages($langs->trans('TicketMarkedAsReadButLogActionNotSaved'), null, 'errors'); - } + if ($object->markAsRead($user) > 0) + { + setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); exit; } else { - array_push($this->errors, $object->error); + $this->errors = $object->error; + $this->error = $object->error; } $action = 'view'; } @@ -396,12 +394,9 @@ class ActionsTicket // Log action in ticket logs table $object->fetch_user($usertoassign); $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); - } else { - setEventMessages($langs->trans('TicketAssignedButLogActionNotSaved'), null, 'errors'); - } + + setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); exit; } else { @@ -436,12 +431,9 @@ class ActionsTicket if ($object->close()) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs)); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); - } else { - setEventMessages($langs->trans('TicketMarkedAsClosedButLogActionNotSaved'), null, 'warnings'); - } + + setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); + $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); header("Location: " . $url); } else { @@ -455,12 +447,9 @@ class ActionsTicket if (($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) && $object->close()) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); - } else { - setEventMessages($langs->trans('TicketMarkedAsClosedButLogActionNotSaved'), null, 'warnings'); - } + + setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); + $url = 'view.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha'); header("Location: " . $url); } else { @@ -495,10 +484,8 @@ class ActionsTicket if ($action == 'set_progression' && $user->rights->ticket->write) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setProgression(GETPOST('progress')); - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogProgressSetTo', GETPOST('progress')); - $ret = $object->createTicketLog($user, $log_action); + $result = $object->setProgression(GETPOST('progress', 'alpha')); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); @@ -529,12 +516,12 @@ class ActionsTicket if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { // prevent browser refresh from reopening ticket several times - if ($object->fk_statut == 8) { - $res = $object->setStatut(4); + if ($object->fk_statut == Ticket::STATUS_CLOSED) { + $res = $object->setStatut(Ticket::STATUS_ASSIGNED); if ($res) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogReopen'); - $ret = $object->createTicketLog($user, $log_action); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); @@ -544,7 +531,7 @@ class ActionsTicket } // Categorisation dans projet elseif ($action == 'classin' && $user->rights->ticket->write) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $object->setProject(GETPOST('projectid')); + $object->setProject(GETPOST('projectid', 'int')); $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); @@ -552,7 +539,7 @@ class ActionsTicket } // Categorisation dans contrat elseif ($action == 'setcontract' && $user->rights->ticket->write) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $object->setContract(GETPOST('contractid')); + $object->setContract(GETPOST('contractid', 'int')); $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); @@ -573,10 +560,7 @@ class ActionsTicket // output the result of comparing two files as plain text $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs'); - } + setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs'); } } @@ -590,7 +574,7 @@ class ActionsTicket if ($res) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); - $ret = $object->createTicketLog($user, $log_action); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); @@ -1013,7 +997,7 @@ class ActionsTicket { global $langs; - if ($action == 'create_ticket') { + if ($action == 'create') { return $langs->trans("CreateTicket"); } elseif ($action == 'edit') { return $langs->trans("EditTicket"); @@ -1498,9 +1482,13 @@ class ActionsTicket print '
'; if ($status == 1) + { $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action - else - $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; + } + else + { + $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; + } print ''; print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 6076cdc4b1b..0eb1de8f8d2 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1396,19 +1396,22 @@ class Ticket extends CommonObject { global $conf, $langs; - if ($this->statut != 9) { // no closed + if ($this->statut != self::STATUS_CANCELED) { // no closed $this->db->begin(); $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket"; $sql .= " SET fk_statut = 1, date_read='" . $this->db->idate(dol_now()) . "'"; $sql .= " WHERE rowid = " . $this->id; - dol_syslog(get_class($this) . "::markAsRead sql=" . $sql); + dol_syslog(get_class($this) . "::markAsRead"); $resql = $this->db->query($sql); if ($resql) { + $this->actionmsg = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs)); + $this->actionmsg2 = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs)); + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('TICKET_MARK_READ', $user); + $result=$this->call_trigger('TICKET_MODIFY', $user); if ($result < 0) { $error++; } diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 0b3a1c101e8..89dbd0acedc 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -49,13 +49,13 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicate $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); -$msg_id = GETPOST('msg_id', 'int'); -$socid = GETPOST('socid', 'int'); -$projectid = GETPOST('projectid', 'int'); +$msg_id = GETPOST('msg_id', 'int'); +$socid = GETPOST('socid', 'int'); +$projectid = GETPOST('projectid', 'int'); $search_fk_soc=GETPOST('$search_fk_soc', 'int')?GETPOST('$search_fk_soc', 'int'):GETPOST('socid', 'int'); $search_fk_project=GETPOST('search_fk_project', 'int')?GETPOST('search_fk_project', 'int'):GETPOST('projectid', 'int'); $search_fk_status = GETPOST('search_fk_statut', 'array'); -$mode = GETPOST('mode', 'alpha'); +$mode = GETPOST('mode', 'alpha'); // Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -79,8 +79,8 @@ $extralabels = $extrafields->fetch_name_optionals_label('ticket'); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="t.datec"; +if (! $sortorder) $sortorder="DESC"; if (GETPOST('search_fk_status', 'alpha') == 'non_closed') $_GET['search_fk_statut'][]='openall'; // For backward compatibility @@ -462,7 +462,7 @@ if ($projectid) print '' . $langs->trans('NewTicket').''; + $newcardbutton = '' . $langs->trans('NewTicket').''; $newcardbutton.= ''; $newcardbutton.= ''; } diff --git a/htdocs/ticket/new.php b/htdocs/ticket/new.php deleted file mode 100644 index 267e3e63847..00000000000 --- a/htdocs/ticket/new.php +++ /dev/null @@ -1,96 +0,0 @@ - - * Copyright (C) 2016 Christophe Battarel - * - * 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/ticket/new.php - * \ingroup ticket - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array('companies', 'other', 'ticket')); - -// Get parameters -$id = GETPOST('id', 'int'); -$socid = GETPOST('socid', 'int'); -$contactid = GETPOST('contactid', 'int'); -$msg_id = GETPOST('msg_id', 'int'); -$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); - -$action = GETPOST('action', 'aZ09'); - -// Protection if external user -if (!$user->rights->ticket->read || !$user->rights->ticket->write) { - accessforbidden(); -} - -$object = new Ticket($db); -$actionobject = new ActionsTicket($db); - - -/* - * Actions - */ - -$actionobject->doActions($action, $object); - - - -/* - * View - */ - -$form = new Form($db); - -$help_url = 'FR:DocumentationModuleTicket'; -$page_title = $actionobject->getTitle($action); -llxHeader('', $page_title, $help_url); - - -if ($action == 'create_ticket') { - $formticket = new FormTicket($db); - - print load_fiche_titre($langs->trans('NewTicket'), '', 'title_ticket'); - - $formticket->withfromsocid = $socid ? $socid : $user->societe_id; - $formticket->withfromcontactid = $contactid ? $contactid : ''; - $formticket->withtitletopic = 1; - $formticket->withnotifytiersatcreate = ($notifyTiers?1:0); - $formticket->withusercreate = 1; - $formticket->withref = 1; - $formticket->fk_user_create = $user->id; - $formticket->withfile = 2; - $formticket->withextrafields = 1; - $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid')); - if (empty($defaultref)) { - $defaultref = ''; - } - - $formticket->showForm(1); -} - -//$somethingshown=$object->showLinkedObjectBlock(); - -// End of page -llxFooter(''); -$db->close(); From 7d37b4c46d373b956c6c7994dab4fc5a86e73aec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 13:04:54 +0100 Subject: [PATCH 31/99] CSS --- htdocs/core/tpl/resource_view.tpl.php | 58 ++++++++++++--------------- htdocs/theme/eldy/style.css.php | 24 ++++++----- htdocs/theme/md/style.css.php | 30 +++++++++++--- 3 files changed, 64 insertions(+), 48 deletions(-) diff --git a/htdocs/core/tpl/resource_view.tpl.php b/htdocs/core/tpl/resource_view.tpl.php index 673045afddc..76a565cf7d6 100644 --- a/htdocs/core/tpl/resource_view.tpl.php +++ b/htdocs/core/tpl/resource_view.tpl.php @@ -13,30 +13,23 @@ $form= new Form($db); print '
'; -if($mode == 'edit' ) -{ - print '
'; - print '
'.$langs->trans('Resource').'
'; - print '
'.$langs->trans('Type').'
'; - print '
'.$langs->trans('Busy').'
'; - print '
'.$langs->trans('Mandatory').'
'; - print '
'; - print ''; -} -else -{ - print '
'; - print '
'.$langs->trans('Resource').'
'; - print '
'.$langs->trans('Type').'
'; - print '
'.$langs->trans('Busy').'
'; - print '
'.$langs->trans('Mandatory').'
'; - print '
'; - print ''; -} +print '
'; + +print '
'; +print '
'.$langs->trans('Resource').'
'; +print '
'.$langs->trans('Type').'
'; +print '
'.$langs->trans('Busy').'
'; +print '
'.$langs->trans('Mandatory').'
'; +print '
'; +print '
'; + +print ''; +print ''; +print ''; +print ''; if( (array) $linked_resources && count($linked_resources) > 0) { - foreach ($linked_resources as $linked_resource) { @@ -46,20 +39,17 @@ if( (array) $linked_resources && count($linked_resources) > 0) if ($mode == 'edit' && $linked_resource['rowid'] == GETPOST('lineid')) { - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + print ''; + print ''; + print ''; print '
'.$object_resource->getNomUrl(1).'
'; print '
'.$object_resource->type_label.'
'; print '
'.$form->selectyesno('busy', $linked_resource['busy']?1:0, 1).'
'; print '
'.$form->selectyesno('mandatory', $linked_resource['mandatory']?1:0, 1).'
'; print '
'; - print ''; + print '
'; } else { @@ -67,7 +57,7 @@ if( (array) $linked_resources && count($linked_resources) > 0) if ($linked_resource['rowid'] == GETPOST('lineid')) $style='style="background: orange;"'; - print '
'; + print '
'; print '
'; print $object_resource->getNomUrl(1); @@ -95,20 +85,22 @@ if( (array) $linked_resources && count($linked_resources) > 0) print ''; print '
'; - print ''; + print '
'; } } } else { - print '
'; + print '
'; print '
'.$langs->trans('NoResourceLinked').'
'; print '
'; print '
'; print '
'; print '
'; - print ''; + print '
'; } +print ''; + print '
'; ?> diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index db4b494179d..3772cb9d86b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3037,7 +3037,7 @@ div.pagination li.paginationafterarrows { box-shadow: unset; -webkit-box-shadow: unset; } -.oddeven, .evenodd, .impair, .nohover .impair:hover, tr.impair td.nohover +.oddeven, .evenodd, .impair, .nohover .impair:hover, tr.impair td.nohover, .tagtr.oddeven { font-family: ; margin-bottom: 1px; @@ -3051,7 +3051,7 @@ div.pagination li.paginationafterarrows { background-color: #; } -.oddeven, .evenodd, .pair, .nohover .pair:hover, tr.pair td.nohover { +.oddeven, .evenodd, .pair, .nohover .pair:hover, tr.pair td.nohover, .tagtr.oddeven { font-family: ; margin-bottom: 1px; color: #202020; @@ -3117,7 +3117,7 @@ div.liste_titre_bydiv { /*width: calc(100% - 1px); 1px more, i don't know why so i remove */ width: calc(100%); } -tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr +tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr, tagtr.liste_titre { height: 26px !important; } @@ -3128,11 +3128,10 @@ div.colorback /* for the form "assign user" on time spent view */ margin-top: 5px; border: 1px solid #ddd; } -div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr +div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_sel, .tagtr.liste_titre, .tagtr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr { background: rgb(); font-weight: ; -/* border-bottom: 1px solid #ddd; */ color: rgb(); font-family: ; @@ -3257,19 +3256,24 @@ div.tabBar .noborder { /* Prepare to remove class pair - impair */ .noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre) { +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) +{ background: linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); } -.noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre) { +.noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), +.noborder .oddeven.tagtr:nth-child(even):not(:last-child) .tagtd:not(.liste_titre) +{ border-bottom: 1px solid #ddd; } .noborder > tbody > tr:nth-child(odd):not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(.liste_titre), -div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre) +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) { background: linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); @@ -3277,7 +3281,9 @@ div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) > .border > tbody > background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); } -.noborder > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre) { +.noborder > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), +.noborder .oddeven.tagtr:nth-child(odd):not(:last-child) .tagtd:not(.liste_titre) +{ border-bottom: 1px solid #ddd; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 85918a43245..b54006f3e6c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2765,6 +2765,10 @@ table.liste th, table.noborder th, table.noborder tr.liste_titre td { table.noborder td, div.noborder form, div.noborder form div, table.tableforservicepart1 td, table.tableforservicepart2 td { padding: 4px 6px 4px 6px; /* t r b l */ } +form.tagtable { + padding: unset !important; + border: unset !important; +} table.liste td, table.noborder td, div.noborder form div { padding: 8px 6px 8px 6px; /* t r b l */ @@ -3079,11 +3083,11 @@ div.liste_titre_bydiv { padding: 2px 0px 2px 0; width: calc(100% - 1px); } -tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr +tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr, tagtr.liste_titre { height: 26px !important; } -div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr +div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_sel, .tagtr.liste_titre, .tagtr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr { background: rgb(); font-weight: ; @@ -3211,28 +3215,42 @@ div .tdtop { /* Prepare to remove class pair - impair */ -.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { +.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) +{ background: linear-gradient(to bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); } -.noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre) { +.noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), +.noborder .tagtr:nth-child(even):not(:last-child) .oddeven.tagtd:not(.liste_titre) +{ border-bottom: 1px solid #ddd; } -.noborder > tbody > tr:nth-child(odd):not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(.liste_titre) { +.noborder > tbody > tr:nth-child(odd):not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), +div:not(.fichecenter):not(.fichehalfleft):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) +{ background: linear-gradient(to bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); } -.noborder > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre) { +.noborder > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), +.noborder .tagtr:nth-child(odd):not(:last-child) .oddeven.tagtd:not(.liste_titre) +{ border-bottom: 1px solid #ddd; } +ul.noborder li:nth-child(even):not(.liste_titre) { + background-color: rgb() !important; +} + /* * Boxes From 1bbf6737ecbf48948cb2c70f52a0ab513d2e3455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 5 Mar 2019 15:27:31 +0100 Subject: [PATCH 32/99] add session newtoken --- htdocs/exports/export.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index ec11f9c1771..6888f638a27 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -761,6 +761,7 @@ if ($step == 3 && $datatoexport) // un formulaire en plus pour recuperer les filtres print '
'; + print ''; print '
'; print ''; print ''; From f402966eb80f2355dd671deca1185f3bbd444940 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 15:48:12 +0100 Subject: [PATCH 33/99] Missing translation --- htdocs/langs/en_US/website.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index f8250ebbc6b..99f0133f175 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -94,4 +94,5 @@ ShowSubcontainers=Include dynamic content InternalURLOfPage=Internal URL of page ThisPageIsTranslationOf=This page/container is translation of ThisPageHasTranslationPages=This page/container has translation -NoWebSiteCreateOneFirst=No website created yet. Create on first. \ No newline at end of file +NoWebSiteCreateOneFirst=No website created yet. Create on first. +GoTo=Go to \ No newline at end of file From 28a4217660442c94a64cf92f4c3506422f73c2fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 15:52:03 +0100 Subject: [PATCH 34/99] Prepare 9.0.1 --- ChangeLog | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 441bbb189b8..cbba717e6a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,21 +7,51 @@ English Dolibarr ChangeLog FIX: #10381 FIX: #10460 compatibility with MariaDB 10.4 FIX: #10485 +FIX: #10638 +FIX: Accountancy - Adding transaction with multicompany uses all the time 1st entity +FIX: actioncomm export: ORDER BY clause is in wrong export property + event type filter does not work FIX: add fk_unit on addline action +FIX: adding css by page if url is externam +FIX: Bad link in menu manager FIX: better test on fetch +FIX: can't add lines on invoices +FIX: Check for old picture name if the new one was not found +FIX: could not create several superadmin in transversal mode +FIX: creation of menu entry with parent id not int +FIX: creation of new left menu entry FIX: Default language of company is not set +FIX: error on setup of password if pass generators have a .old file. FIX: error report not returned FIX: expedition: reset status on rollback + replace hardcoded status with const +FIX: fetch module / pos source +FIX: fk_default_warehouse missing in group by +FIX: function sendEmailsReminder isn't completely developed, then MAIN_FEATURES_LEVEL must be 2 to "use" it +FIX: if empty error message, we just see "error" displayed +FIX: label of bank account FIX: line edit template: keep fk_parent_line +FIX: Mark credit note as available for credit note in other currency +FIX: missing access security checking with multicompany +FIX: missing entity filter in function "build_filterField()" (export module) +FIX: missing $ismultientitymanaged for previous/next ref FIX: Missing province in export of invoice FIX: must fetch member in current entity +FIX: positive values creating diff on addline rounding +FIX: positive values IN supplier credit notes creating diff on addline rounding FIX: Price in combo list of service does not use the correct price level -FIX: supplier invoice payment total doesnt care about deposit or credit +FIX: project_title for display of getNomUrl() +FIX: same thing here +FIX: Show button POS Ticket only if invoice was generated by POS +FIX: supplier invoice payment total doesn't care about deposit or credit FIX: supplier invoice product stats total ht is line total not invoice total +FIX: The notes was also copied on invoice +FIX: Transaction on leave approval and decrease ko if setup not complete FIX: Translation not loaded by scheduled jobs +FIX: [URGENT] broken feature, "$usercancreate" is for Dolibarr 9 +FIX: we want to be able to reopen fourn credit note +FIX: wrong feature2 when user rights "group_advance" is used FIX: wrong merged conflict FIX: wrong tests on fetch -NEW: Add protection to avoid packaging if files non indexed exists into +NEW: Add protection to avoid packaging if files non indexed exists ***** ChangeLog for 9.0.0 compared to 8.0.0 ***** For Users: From e66447eabc8e43b952e41332189873114990e63f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 15:53:57 +0100 Subject: [PATCH 35/99] Fix phpcs --- htdocs/admin/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 6c3ed1f294b..df2d2b09ee6 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -497,7 +497,7 @@ print '
'.$langs->trans("Entities").'
'; print ''; print '
'; -if (GETPOST('info','int') > 0) +if (GETPOST('info', 'int') > 0) { if (function_exists('password_hash')) { From bbbffae72b6ff95324c52d8000982f02ddf6e154 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 16:27:19 +0100 Subject: [PATCH 36/99] Fix phpcs --- htdocs/core/class/html.formticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index c255145ee58..03ee95619da 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -352,7 +352,7 @@ class FormTicket { $formproject=new FormProjets($this->db); print ''; - print $formproject->select_projects(-1, GETPOST('projectid','int'), 'projectid', 0, 0, 1, 1); + print $formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1); print ''; } From 1e95802a4197ff16fd9e488fa1e2fec6adfb9824 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 16:29:24 +0100 Subject: [PATCH 37/99] Fix phpcs --- htdocs/ticket/class/actions_ticket.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 39d51017c41..f978642311c 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -116,9 +116,9 @@ class ActionsTicket /* * Add file in email form */ - if (GETPOST('addfile')) { + if (GETPOST('addfile', 'alpha')) { // altairis : allow files from public interface - if (GETPOST('track_id')) { + if (GETPOST('track_id', 'alpha')) { $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); } @@ -140,7 +140,7 @@ class ActionsTicket /* * Remove file in email form */ - if (GETPOST('removedfile')) { + if (GETPOST('removedfile', 'alpha')) { // altairis : allow files from public interface if (GETPOST('track_id')) { $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); @@ -160,7 +160,7 @@ class ActionsTicket ////} } - if (GETPOST('add','alpha') && $user->rights->ticket->write) { + if (GETPOST('add', 'alpha') && $user->rights->ticket->write) { $error = 0; if (!GETPOST("subject")) { From 2ebffb2ffe2fc03c47f9379d4b7c99154d34cacd Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 5 Mar 2019 16:29:53 +0100 Subject: [PATCH 38/99] FIX: date in ticket.class.php dolibarize date --- htdocs/ticket/class/ticket.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 0eb1de8f8d2..c603c0489cb 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -528,9 +528,12 @@ class Ticket extends CommonObject $this->severity_label = $label_severity; $this->datec = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_read = $this->db->jdate($obj->date_read); + $this->date_validation = $this->db->jdate($obj->date_read); $this->date_close = $this->db->jdate($obj->date_close); $this->tms = $this->db->jdate($obj->tms); + $this->date_modification = $this->db->jdate($obj->tms); $this->fetch_optionals(); From 756b9ca07fe974657aa2a984ae7f39f47f0b432a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 16:51:16 +0100 Subject: [PATCH 39/99] Fix phpunit --- test/phpunit/TicketTest.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/test/phpunit/TicketTest.php b/test/phpunit/TicketTest.php index 175ced68bda..4f3d06fc7cc 100644 --- a/test/phpunit/TicketTest.php +++ b/test/phpunit/TicketTest.php @@ -332,33 +332,6 @@ class TicketTest extends PHPUnit_Framework_TestCase return $localobject; } - /** - * testTicketcreateTicketLog - * - * @param Ticket $localobject Ticket - * @return int - * - * @depends testTicketFetch - * The depends says test is run only if previous is ok - */ - public function testTicketcreateTicketLog($localobject) - { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; - - - $message = 'Test ticket log'; - $noemail = 1; - $result=$localobject->createTicketLog($user, $message, $noemail); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - - $this->assertGreaterThan(0, $result); - return $localobject; - } - /** * testTicketclose * From 598d1fc9143c28b75ee2e311a9e1651d987cc177 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 5 Mar 2019 16:53:36 +0100 Subject: [PATCH 40/99] FIX : extrafields always visible on view mode --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5bb557cac2c..c16ee425cad 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6299,6 +6299,7 @@ abstract class CommonObject } if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + elseif($mode == 'view' && empty($visibility)) continue; if (empty($perms)) continue; // Load language if required From 4aa93181d30ba1087fd96b1ba8200fa2c1fa53a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 18:17:26 +0100 Subject: [PATCH 41/99] Fix phpunit --- test/phpunit/MouvementStockTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index 597f4b88de6..e422d5e10ca 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -163,17 +163,17 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase // Do a list of movement into warehouse 1 // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 - $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); + $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1', '', '', '', '', 0, 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); + $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2', '', '', '', '', 0, 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3', 'Inventory Code Test'); + $result=$localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3', '', '', '', '', 0, 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); @@ -191,17 +191,17 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase // Do same but into warehouse 2 // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 - $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); + $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2', '', '', '', '', 0, 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); + $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2', '', '', '', '', 0, 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 - $result=$localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); + $result=$localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2', '', '', '', '', 0, 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); From db5dd7f9aa0f4e1b53bdbdfaa3e3040049b4a814 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 18:19:37 +0100 Subject: [PATCH 42/99] Fix phpunit --- htdocs/product/stock/class/mouvementstock.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index bf267c9985e..130bece6372 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -711,15 +711,16 @@ class MouvementStock extends CommonObject * @param date $sellby sell-by date * @param string $batch batch number * @param int $id_product_batch Id product_batch + * @param string $inventorycode Inventory code * @return int <0 if KO, >0 if OK */ - public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0) + public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0, $inventorycode='') { global $conf; $skip_batch = empty($conf->productbatch->enabled); - return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, '', $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); + return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, $inventorycode, $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); } /** @@ -736,15 +737,16 @@ class MouvementStock extends CommonObject * @param string $batch batch number * @param string $datem Force date of movement * @param int $id_product_batch Id product_batch + * @param string $inventorycode Inventory code * @return int <0 if KO, >0 if OK */ - public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0) + public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0, $inventorycode='') { global $conf; $skip_batch = empty($conf->productbatch->enabled); - return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, '', $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); + return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, $inventorycode, $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); } From c06d2f6c3b019a976458e3bc89d8dd1ffb398435 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 18:22:03 +0100 Subject: [PATCH 43/99] Remove warning --- htdocs/install/upgrade2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index b1f0fc68254..4e5e116a599 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -186,7 +186,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 { // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray=preg_split('/[\.-]/',isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:$conf->global->MAIN_VERSION_LAST_INSTALL); + $dolibarrlastupgradeversionarray=preg_split('/[\.-]/',isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:(isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:'')); // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec // dans la 1ere colonne, la description de l'action a faire From b4851e3d40e9ba0d74384fc39eba06172d1186fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 5 Mar 2019 21:54:51 +0100 Subject: [PATCH 44/99] Update mailinglist_mymodule_myobject.modules.php Warning: Declaration of mailing_***********::add_to_target($mailing_id) should be compatible with MailingTargets::add_to_target($mailing_id, $cibles) --- .../modules/mailings/mailinglist_mymodule_myobject.modules.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index 83644cd1f0e..07419af532d 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -97,9 +97,10 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets * This is the main function that returns the array of emails * * @param int $mailing_id Id of emailing + * @param array $cibles Array with targets * @return int <0 if error, number of emails added if ok */ - public function add_to_target($mailing_id) + public function add_to_target($mailing_id, $cibles) { // phpcs:enable $target = array(); From 2745f986441023472858126a55698d2d15e18f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 5 Mar 2019 22:10:46 +0100 Subject: [PATCH 45/99] PSR2.Classes.PropertyDeclaration.VarUsed --- dev/setup/codesniffer/ruleset.xml | 1 + htdocs/comm/propal/class/propal.class.php | 88 +++++++++---------- htdocs/core/class/commonorder.class.php | 2 +- htdocs/core/class/stats.class.php | 6 +- .../modules/syslog/mod_syslog_chromephp.php | 6 +- .../core/modules/syslog/mod_syslog_file.php | 4 +- .../core/modules/syslog/mod_syslog_syslog.php | 2 +- .../class/expensereportstats.class.php | 10 +-- 8 files changed, 60 insertions(+), 59 deletions(-) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index b6f62aede64..d8fff2265e9 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -428,4 +428,5 @@ + diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 304eccf9bb7..ad5197512d4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3526,13 +3526,13 @@ class Propal extends CommonObject if ($option == '') { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id. $get_params; } - if ($option == 'compta') { // deprecated + elseif ($option == 'compta') { // deprecated $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id. $get_params; } - if ($option == 'expedition') { + elseif ($option == 'expedition') { $url = DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id. $get_params; } - if ($option == 'document') { + elseif ($option == 'document') { $url = DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id. $get_params; } @@ -3646,68 +3646,68 @@ class PropaleLigne extends CommonObjectLine */ public $table_element='propaldet'; - var $oldline; + public $oldline; // From llx_propaldet - var $fk_propal; - var $fk_parent_line; - var $desc; // Description ligne - var $fk_product; // Id produit predefini + public $fk_propal; + public $fk_parent_line; + public $desc; // Description ligne + public $fk_product; // Id produit predefini /** * @deprecated * @see product_type */ - var $fk_product_type; + public $fk_product_type; /** * Product type. * @var int * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE */ - var $product_type = Product::TYPE_PRODUCT; + public $product_type = Product::TYPE_PRODUCT; - var $qty; - var $tva_tx; - var $subprice; - var $remise_percent; - var $fk_remise_except; + public $qty; + public $tva_tx; + public $subprice; + public $remise_percent; + public $fk_remise_except; - var $rang = 0; + public $rang = 0; - var $fk_fournprice; - var $pa_ht; - var $marge_tx; - var $marque_tx; + public $fk_fournprice; + public $pa_ht; + public $marge_tx; + public $marque_tx; - var $special_code; // Tag for special lines (exlusive tags) + public $special_code; // Tag for special lines (exlusive tags) // 1: frais de port // 2: ecotaxe // 3: option line (when qty = 0) - var $info_bits = 0; // Liste d'options cumulables: + public $info_bits = 0; // Liste d'options cumulables: // Bit 0: 0 si TVA normal - 1 si TVA NPR // Bit 1: 0 ligne normale - 1 si ligne de remise fixe - var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne - var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne - var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne + public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne /** * @deprecated * @see $remise_percent, $fk_remise_except */ - var $remise; + public $remise; /** * @deprecated * @see subprice */ - var $price; + public $price; // From llx_product /** * @deprecated * @see product_ref */ - var $ref; + public $ref; /** * Product reference * @var string @@ -3717,7 +3717,7 @@ class PropaleLigne extends CommonObjectLine * @deprecated * @see product_label */ - var $libelle; + public $libelle; /** * Product label * @var string @@ -3729,25 +3729,25 @@ class PropaleLigne extends CommonObjectLine */ public $product_desc; - var $localtax1_tx; // Local tax 1 - var $localtax2_tx; // Local tax 2 - var $localtax1_type; // Local tax 1 type - var $localtax2_type; // Local tax 2 type - var $total_localtax1; // Line total local tax 1 - var $total_localtax2; // Line total local tax 2 + public $localtax1_tx; // Local tax 1 + public $localtax2_tx; // Local tax 2 + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type + public $total_localtax1; // Line total local tax 1 + public $total_localtax2; // Line total local tax 2 - var $date_start; - var $date_end; + public $date_start; + public $date_end; - var $skip_update_total; // Skip update price total for special lines + public $skip_update_total; // Skip update price total for special lines // Multicurrency - var $fk_multicurrency; - var $multicurrency_code; - var $multicurrency_subprice; - var $multicurrency_total_ht; - var $multicurrency_total_tva; - var $multicurrency_total_ttc; + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Class line Contructor diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 9d9445df91c..ddaef527630 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -82,7 +82,7 @@ abstract class CommonOrderLine extends CommonObjectLine * @deprecated * @see subprice */ - var $price; + public $price; /** * Unit price before taxes diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index b35e9947644..b06f1deb4c3 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -29,9 +29,9 @@ */ abstract class Stats { - protected $db; - var $_lastfetchdate=array(); // Dates of cache file read by methods - var $cachefilesuffix=''; // Suffix to add to name of cache file (to avoid file name conflicts) + protected $db; + private $_lastfetchdate=array(); // Dates of cache file read by methods + public $cachefilesuffix=''; // Suffix to add to name of cache file (to avoid file name conflicts) /** * Return nb of elements by month for several years diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php index 8ace164fce6..f3d34c4a9cd 100644 --- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_chromephp.php @@ -7,7 +7,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php'; */ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface { - var $code = 'chromephp'; + public $code = 'chromephp'; /** * Return name of logger @@ -50,7 +50,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning', 'ChromePhp.class.php'); } - + /** * Is the module active ? * @@ -159,7 +159,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface $res = @include_once 'ChromePhp.php'; if (! $res) $res=@include_once 'ChromePhp.class.php'; set_include_path($oldinclude); - + ob_start(); // To be sure headers are not flushed until all page is completely processed if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']); elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']); diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index ced2cf9133b..4c59eb5ef98 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -7,8 +7,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php'; */ class mod_syslog_file extends LogHandler implements LogHandlerInterface { - var $code = 'file'; - var $lastTime = 0; + public $code = 'file'; + public $lastTime = 0; /** * Return name of logger diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index 26232e91ed5..97a37ff2c8a 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -7,7 +7,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php'; */ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface { - var $code = 'syslog'; + public $code = 'syslog'; /** * Return name of logger diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 082e3ce016e..5edf301ac25 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -35,12 +35,12 @@ class ExpenseReportStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** * Constructor From 6c6a1a02f070bbc6a7ccce272ba84732199c2a96 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 11:06:35 +0100 Subject: [PATCH 46/99] allow this script to be included in custom themes --- htdocs/theme/eldy/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1f58937d879..35f6f56c57c 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -61,7 +61,7 @@ if (defined('THEME_ONLY_CONSTANT')) return; session_cache_limiter('public'); -require_once '../../main.inc.php'; +require_once __DIR__.'/../../main.inc.php'; // __DIR__ allow this script to be included in custom themes require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) From 1ee52131b43a2c7a0df605ef60a0fa120bccf818 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 11:49:41 +0100 Subject: [PATCH 47/99] Fix badge for sf download --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dfd1a8a750..ad1702fffe4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DOLIBARR ERP & CRM -![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) +![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) |6|7|8|9|develop| From b56cd11f021e76fba68d134e3a0e26985e2d7882 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Wed, 6 Mar 2019 12:00:55 +0100 Subject: [PATCH 48/99] Fix default contact id for update and clone actions in event card --- htdocs/comm/action/card.php | 8 ++++++++ htdocs/comm/action/class/actioncomm.class.php | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 8458207a5d8..6ad881d141c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -160,6 +160,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { if ($id > 0) { $object->fetch($id); + if (!empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } $result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid')); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); @@ -431,6 +435,10 @@ if ($action == 'update') $object->socpeopleassigned = array(); foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); $object->contactid = GETPOST("contactid", 'int'); + if (empty($object->contactid) && !empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } $object->fk_project = GETPOST("projectid", 'int'); $object->note = GETPOST("note", "none"); // deprecated $object->note_private= GETPOST("note", "none"); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fba891a848a..56e5e68b2f7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -270,7 +270,7 @@ class ActionComm extends CommonObject $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); } - if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated + //if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated $userownerid=$this->userownerid; @@ -656,7 +656,7 @@ class ActionComm extends CommonObject $this->fk_project = $obj->fk_project; // To have fetch_project method working $this->societe->id = $obj->fk_soc; // deprecated - $this->contact->id = $obj->fk_contact; // deprecated + //$this->contact->id = $obj->fk_contact; // deprecated $this->fk_element = $obj->elementid; $this->elementid = $obj->elementid; @@ -867,7 +867,7 @@ class ActionComm extends CommonObject } $socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0)); - $contactid=($this->contactid?$this->contactid:((isset($this->contact->id) && $this->contact->id > 0) ? $this->contact->id : 0)); + $contactid=($this->contactid?$this->contactid:0); $userownerid=($this->userownerid?$this->userownerid:0); $userdoneid=($this->userdoneid?$this->userdoneid:0); From 0ff29051802d477a47071e75d5ebba9744b48f99 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 6 Mar 2019 12:10:24 +0100 Subject: [PATCH 49/99] FIX : we need to keep originline special_code --- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- htdocs/fourn/facture/card.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 309230a4dcc..b0351252c0b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1386,7 +1386,7 @@ class FactureFournisseur extends CommonInvoice * * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='') + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='', $special_code='') { dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1481,7 +1481,7 @@ class FactureFournisseur extends CommonInvoice $this->line->total_localtax1=$total_localtax1; $this->line->total_localtax2=$total_localtax2; $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); - $this->line->special_code=$this->special_code; + $this->line->special_code=!empty($special_code) ? $special_code : $this->special_code; $this->line->fk_parent_line=$this->fk_parent_line; $this->line->origin=$this->origin; $this->line->origin_id=$origin_id; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index cc9164b753f..3e7df0b27f3 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -716,7 +716,10 @@ if (empty($reshook)) 0, $lines[$i]->array_options, $lines[$i]->fk_unit, - $lines[$i]->id + $lines[$i]->id, + 0, + '', + $lines[$i]->special_code ); if ($result < 0) From 1ab3949e9c0e0a4cc92a5c8b8c0a488ea8bfb193 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 13:01:01 +0100 Subject: [PATCH 50/99] Optimize js code --- htdocs/core/tpl/objectline_create.tpl.php | 73 ++++++++++------------- 1 file changed, 30 insertions(+), 43 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 8b577b71bcc..2cc990056da 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -596,6 +596,28 @@ if (! empty($usemargins) && $user->rights->margins->creer) /* JQuery for product free or predefined select */ jQuery(document).ready(function() { + jQuery("#price_ht").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { + jQuery("#price_ttc").val(''); + jQuery("#multicurrency_subprice").val(''); + } + }); + jQuery("#price_ttc").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#multicurrency_subprice").val(''); + } + }); + jQuery("#multicurrency_subprice").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#price_ttc").val(''); + } + }); + $("#prod_entry_mode_free").on( "click", function() { setforfree(); }); @@ -662,10 +684,7 @@ jQuery(document).ready(function() { $.post('/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', { 'idprod': $(this).val() }, function(data) { if (data && data.length > 0) { - var options = ''; - var defaultkey = ''; - var defaultprice = ''; - var bestpricefound = 0; + var options = ''; var defaultkey = ''; var defaultprice = ''; var bestpricefound = 0; var bestpriceid = 0; var bestpricevalue = 0; var pmppriceid = 0; var pmppricevalue = 0; @@ -796,61 +815,29 @@ jQuery(document).ready(function() { setforpredef(); - }); /* Function to set fields from choice */ function setforfree() { console.log("Call setforfree. We show most fields"); - jQuery("#search_idprod").val(''); - jQuery("#idprod").val(''); jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product - jQuery("#search_idprodfournprice").val(''); jQuery("#prod_entry_mode_free").prop('checked',true).change(); jQuery("#prod_entry_mode_predef").prop('checked',false).change(); - jQuery("#price_ht").show(); - jQuery("#multicurrency_price_ht").show(); - jQuery("#price_ttc").show(); // May not exist - jQuery("#fourn_ref").show(); - jQuery("#tva_tx").show(); - jQuery("#buying_price").val('').show(); + jQuery("#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(''); + jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); jQuery("#fournprice_predef").hide(); - jQuery("#title_vat").show(); - jQuery("#title_up_ht").show(); - jQuery("#title_up_ht_currency").show(); - jQuery("#title_up_ttc").show(); - jQuery("#title_up_ttc_currency").show(); - jQuery("#np_marginRate").show(); // May not exist - jQuery("#np_markRate").show(); // May not exist - jQuery(".np_marginRate").show(); // May not exist - jQuery(".np_markRate").show(); // May not exist - jQuery("#units, #title_units").show(); } function setforpredef() { console.log("Call setforpredef. We hide some fields and show dates"); jQuery("#select_type").val(-1); - jQuery("#prod_entry_mode_free").prop('checked',false).change(); jQuery("#prod_entry_mode_predef").prop('checked',true).change(); - jQuery("#price_ht").val('').hide(); - jQuery("#multicurrency_price_ht").hide(); - jQuery("#price_ttc").hide(); // May not exist - jQuery("#fourn_ref").hide(); - jQuery("#tva_tx").hide(); + jQuery("#price_ht").val('') + jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); - jQuery("#title_vat").hide(); - jQuery("#title_up_ht").hide(); - jQuery("#title_up_ht_currency").hide(); - jQuery("#title_up_ttc").hide(); - jQuery("#title_up_ttc_currency").hide(); - jQuery("#np_marginRate").hide(); // May not exist - jQuery("#np_markRate").hide(); // May not exist - jQuery(".np_marginRate").hide(); // May not exist - jQuery(".np_markRate").hide(); // May not exist - jQuery("#units, #title_units").hide(); - - jQuery('#trlinefordates').show(); - jQuery('.divlinefordates').show(); + jQuery('#trlinefordates, .divlinefordates').show(); } From d4409ffb0886e8dc34c6b6cef8cd3f9075aab36e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 14:18:58 +0100 Subject: [PATCH 51/99] Restore menu MRP on new eldy code --- htdocs/core/menus/standard/eldy.lib.php | 66 ++++++++++++++---------- htdocs/theme/eldy/main_menu_fa_icons.css | 8 +++ htdocs/theme/md/style.css.php | 4 ++ 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index fcc1f1aea3a..4383ae07e75 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -183,23 +183,33 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // MRP - $tmpentry = array( - 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)), - 'perms'=>(! empty($user->rights->bom->read) || ! empty($user->rights->mrp->read)), - 'module'=>'bom|mrp', + $menu_arr[] = array( + 'name' => 'TMenuMRP', + 'link' => '/bom/bom_list.php?mainmenu=mrp&leftmenu=', + 'title' => $langs->trans("TMenuMRP"), + 'level' => 0, + 'enabled' => $showmode = isVisibleToUserType + ( + $type_user, + $tmpentry = array( + 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)), + 'perms'=>(! empty($user->rights->bom->read) || ! empty($user->rights->mrp->read)), + 'module'=>'bom|mrp', + ), + $listofmodulesforexternal + ), + 'target' => $atarget, + 'mainmenu' => "mrp", + 'leftmenu' => '', + 'position' => 30, + 'id' => $id, + 'idsel' => 'mrp', + 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 'class="tmenusel"' : 'class="tmenu"', + 'prefix' => '', + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 0 : 1 ), + 'loadLangs' => array("projects"), + 'submenus' => array(), ); - $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); - if ($showmode) - { - $classname=""; - if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } - else $classname = 'class="tmenu"'; - $idsel='products'; - - $chaine=$langs->trans("TMenuMRP"); - - $menu->add('/bom/bom_list.php?mainmenu=mrp&leftmenu=', $chaine, 0, $showmode, $atarget, "bom", '', 30, $id, $idsel, $classname); - } // Projects $menu_arr[] = array( @@ -328,9 +338,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'idsel' => 'bank', 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => '', - + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 0 : 1 ), - + 'loadLangs' => array("compta","banks"), 'submenus' => array(), ); @@ -359,9 +369,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'idsel' => 'accountancy', 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => '', - + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 0 : 1 ), - + 'loadLangs' => array("compta"), 'submenus' => array(), ); @@ -390,9 +400,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'idsel' => 'hrm', 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => '', - + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 0 : 1 ), - + 'loadLangs' => array("holiday"), 'submenus' => array(), ); @@ -421,31 +431,31 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'idsel' => 'tools', 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 'class="tmenusel"' : 'class="tmenu"', 'prefix' => '', - + 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 0 : 1 ), - + 'loadLangs' => array("other"), 'submenus' => array(), ); - + // Add menus foreach($menu_arr as $key => $smenu) { $smenu = (object) $smenu; - + if( $smenu->enabled ) { if($langs->session) { $_SESSION['idmenu']=''; } - + // Load Langue if(! empty($smenu->loadLangs)) { $langs->loadLangs($smenu->loadLangs); } - + // Trans title $mtitle = ''; if(is_array($smenu->title)) diff --git a/htdocs/theme/eldy/main_menu_fa_icons.css b/htdocs/theme/eldy/main_menu_fa_icons.css index 58890786111..57d422b8395 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.css +++ b/htdocs/theme/eldy/main_menu_fa_icons.css @@ -118,6 +118,14 @@ div.mainmenu.products::before { font-size: 1.5em; } +div.mainmenu.mrp::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f468"; + color: white; + font-size: 1.5em; +} + div.mainmenu.project::before { font-family: "Font Awesome 5 Free"; font-weight: 900; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 6748bcb215a..1f98c2d25ca 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1764,6 +1764,10 @@ div.mainmenu.products { background-image: url(); } +div.mainmenu.mrp { + background-image: url(); +} + div.mainmenu.project { background-image: url(); } From 0c2a0c643bf50d9639d111e82afab39bdd6eb8ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 14:33:05 +0100 Subject: [PATCH 52/99] NEW Performance enhancement: Replace dirname(__FILE__) with __DIR__ --- htdocs/core/lib/website.lib.php | 5 ++--- htdocs/holiday/common.inc.php | 2 +- htdocs/install/upgrade.php | 2 +- htdocs/install/upgrade2.php | 2 +- htdocs/modulebuilder/template/scripts/myobject.php | 2 +- htdocs/website/index.php | 14 +++++++------- htdocs/website/samples/wrapper.html | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 40c12d302c9..972a271c140 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -22,7 +22,6 @@ */ - /** * Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content. * Used to ouput the page on the Preview from backoffice. @@ -661,7 +660,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent =''; $tplcontent.= " Date: Wed, 6 Mar 2019 16:37:02 +0100 Subject: [PATCH 53/99] add contant DISPLAY_DISCOUNTED_SUPPLIER_PRICE --- htdocs/core/class/html.form.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a83ff1083e6..023adfae7a5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2747,23 +2747,23 @@ class Form } if ($objp->quantity == 1) { - $opt.= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/"; - $outval.= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/"; + $opt.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; + $outval.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/"; $opt.= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding $outval.=$langs->transnoentities("Unit"); } else { - $opt.= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; - $outval.= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; + $opt.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; + $outval.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; $opt.= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding $outval.= ' '.$langs->transnoentities("Units"); } if ($objp->quantity >= 1) { - $opt.=" (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding - $outval.=" (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding + $opt.=" (".price($objp->unitprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding + $outval.=" (".price($objp->unitprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding } if ($objp->remise_percent >= 1) { @@ -2854,7 +2854,7 @@ class Form $langs->load('stocks'); $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, pfp.fk_soc,"; - $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,"; + $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,"; $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; @@ -2914,7 +2914,7 @@ class Form } if ($objp->quantity == 1) { - $opt.= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/"; + $opt.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; } $opt.= $objp->quantity.' '; @@ -2930,7 +2930,7 @@ class Form if ($objp->quantity > 1) { $opt.=" - "; - $opt.= price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); + $opt.= price($objp->unitprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); } if ($objp->duration) $opt .= " - ".$objp->duration; $opt .= "\n"; From 4e533b2a91bd5950f70b4a34236628660624bcda Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 16:41:28 +0100 Subject: [PATCH 54/99] better constant test --- htdocs/core/class/html.form.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 023adfae7a5..0618e15afe8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2747,23 +2747,23 @@ class Form } if ($objp->quantity == 1) { - $opt.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; - $outval.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/"; + $opt.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; + $outval.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/"; $opt.= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding $outval.=$langs->transnoentities("Unit"); } else { - $opt.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; - $outval.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; + $opt.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; + $outval.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; $opt.= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding $outval.= ' '.$langs->transnoentities("Units"); } if ($objp->quantity >= 1) { - $opt.=" (".price($objp->unitprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding - $outval.=" (".price($objp->unitprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding + $opt.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding + $outval.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding } if ($objp->remise_percent >= 1) { @@ -2914,7 +2914,7 @@ class Form } if ($objp->quantity == 1) { - $opt.= price($objp->fprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; + $opt.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; } $opt.= $objp->quantity.' '; @@ -2930,7 +2930,7 @@ class Form if ($objp->quantity > 1) { $opt.=" - "; - $opt.= price($objp->unitprice * ($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); + $opt.= price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); } if ($objp->duration) $opt .= " - ".$objp->duration; $opt .= "\n"; From 7a512d587c07f5d5b256197ab702f486562fc815 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 16:44:06 +0100 Subject: [PATCH 55/99] remove specific entry in gitignore --- htdocs/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/.gitignore b/htdocs/.gitignore index aa007a70ae5..ac35d8fab2f 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -28,4 +28,3 @@ /nomenclature* /of/ /workstation/ -/theme/dolipro* \ No newline at end of file From cb39c6f3ce5cbe91e94dd5186d2ec317c059a8e9 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 16:48:48 +0100 Subject: [PATCH 56/99] remove specific entry in gitignore --- htdocs/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/.gitignore b/htdocs/.gitignore index aa007a70ae5..ac35d8fab2f 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -28,4 +28,3 @@ /nomenclature* /of/ /workstation/ -/theme/dolipro* \ No newline at end of file From a6b759bd879701405e1db3fab52c7944fcca75c6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 16:50:28 +0100 Subject: [PATCH 57/99] remove specific entry in gitignore --- htdocs/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/.gitignore b/htdocs/.gitignore index aa007a70ae5..ac35d8fab2f 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -28,4 +28,3 @@ /nomenclature* /of/ /workstation/ -/theme/dolipro* \ No newline at end of file From c2070190f2bb5ad8910d037932a8c198207bfd09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 16:51:35 +0100 Subject: [PATCH 58/99] phpcs fix --- htdocs/core/menus/standard/eldy.lib.php | 35 +++++++++---------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4383ae07e75..04f379b746f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -91,8 +91,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/adherents/index.php?mainmenu=members&leftmenu=', 'title' => "MenuMembers", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled' => (! empty($conf->adherent->enabled) ) , @@ -120,8 +119,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/societe/index.php?mainmenu=companies&leftmenu=', 'title' => "ThirdParties", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=> ( ( ! empty($conf->societe->enabled) && @@ -155,11 +153,10 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ? ( array("TMenuProducts" , " | " ,"TMenuServices") ) : (! empty($conf->product->enabled)? "TMenuProducts" : "TMenuServices" ), 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( - 'enabled'=> ( ( ! empty($conf->societe->enabled) && + 'enabled'=> (( ! empty($conf->societe->enabled) && ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) ) || ! empty($conf->fournisseur->enabled) @@ -188,8 +185,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/bom/bom_list.php?mainmenu=mrp&leftmenu=', 'title' => $langs->trans("TMenuMRP"), 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)), @@ -219,8 +215,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2)?"Leads":"Projects") : "LeadsOrProjects", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0), @@ -248,8 +243,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/comm/index.php?mainmenu=commercial&leftmenu=', 'title' => "Commercial", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=>(! empty($conf->propal->enabled) || @@ -283,8 +277,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', 'title' => "MenuFinancial", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=>(! empty($conf->facture->enabled) || @@ -320,8 +313,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/compta/bank/list.php?mainmenu=bank&leftmenu=', 'title' => "MenuBankCash", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), @@ -351,8 +343,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/accountancy/index.php?mainmenu=accountancy&leftmenu=', 'title' => "MenuAccountancy", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)), @@ -382,8 +373,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/hrm/index.php?mainmenu=hrm&leftmenu=', 'title' => "HRM", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), @@ -413,8 +403,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'link' => '/core/tools.php?mainmenu=tools&leftmenu=', 'title' => "Tools", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType - ( + 'enabled' => $showmode = isVisibleToUserType( $type_user, $tmpentry = array( 'enabled'=>1, From ceab55f26b47b86e4b4b3f1b59b89568491e2e32 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 17:07:51 +0100 Subject: [PATCH 59/99] NEW : add constant MAIN_DEFAULT_LANGUAGE_FILTER --- htdocs/core/class/html.formadmin.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 1758480af8f..166e0ce2044 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -62,7 +62,9 @@ class FormAdmin public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0) { // phpcs:enable - global $langs; + global $conf, $langs; + + if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1; $langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); From 0f8f4fbc15e2d8d7796f6c5ccfa4fafb72978662 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 17:12:39 +0100 Subject: [PATCH 60/99] bad branching --- htdocs/theme/eldy/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 35f6f56c57c..cecfc3e5efa 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -61,7 +61,7 @@ if (defined('THEME_ONLY_CONSTANT')) return; session_cache_limiter('public'); -require_once __DIR__.'/../../main.inc.php'; // __DIR__ allow this script to be included in custom themes +require_once '/../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) From b4397806fcd66667ba85269f44facb8897540cae Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 17:14:05 +0100 Subject: [PATCH 61/99] bad branching 2 --- htdocs/theme/eldy/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index cecfc3e5efa..1f58937d879 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -61,7 +61,7 @@ if (defined('THEME_ONLY_CONSTANT')) return; session_cache_limiter('public'); -require_once '/../../main.inc.php'; +require_once '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) From 4382a26c879194d55b84b2cf29af6e56b66997ed Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 17:21:44 +0100 Subject: [PATCH 62/99] sort list of models alphabetically --- htdocs/core/class/html.formfile.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5e875be176d..a3134f641a1 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -677,11 +677,12 @@ class FormFile $out.= ''; $addcolumforpicto=($delallowed || $printer || $morepicto); - $out.= ''; + $out.= ''; // Model if (! empty($modellist)) { + asort($modellist); $out.= ''.$langs->trans('Model').' '; if (is_array($modellist) && count($modellist) == 1) // If there is only one element { From 8f8fe0648ebe771fe9b25cbf3691a5929304f38f Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 17:24:50 +0100 Subject: [PATCH 63/99] fix bad copy paste --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index a3134f641a1..2577d70e549 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -677,7 +677,7 @@ class FormFile $out.= ''; $addcolumforpicto=($delallowed || $printer || $morepicto); - $out.= ''; + $out.= ''; // Model if (! empty($modellist)) From 414bac6fb48e394cb35555a30c9e590c4d05acc2 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 17:56:43 +0100 Subject: [PATCH 64/99] avoid logging empty query --- htdocs/core/db/mysqli.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 6c3bfd2362f..1b040ddfa18 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -256,6 +256,8 @@ class DoliDBMysqli extends DoliDB $query = trim($query); + if (empty($query)) return null; + if (! in_array($query, array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG); if (! $this->database_name) From 8743b43fdbcc3c3433ede604318e007f6f4cc063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:01:18 +0100 Subject: [PATCH 65/99] add oldcopy of category before updating --- htdocs/categories/edit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index a85c320a992..9416ddae748 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -81,6 +81,7 @@ if ($cancel) // Action mise a jour d'une categorie if ($action == 'update' && $user->rights->categorie->creer) { + $object->oldcopy = dol_clone($object); $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; From 401ad659758df2cc1f236251cae5ae64ba3e2ec7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 18:04:36 +0100 Subject: [PATCH 66/99] Fix API explorer was broken due to corrupted API --- .../{api_bom.class.php => api_boms.class.php} | 77 +++++++++---------- htdocs/commande/class/api_orders.class.php | 6 +- .../template/class/api_mymodule.class.php | 30 ++++---- 3 files changed, 55 insertions(+), 58 deletions(-) rename htdocs/bom/class/{api_bom.class.php => api_boms.class.php} (84%) diff --git a/htdocs/bom/class/api_bom.class.php b/htdocs/bom/class/api_boms.class.php similarity index 84% rename from htdocs/bom/class/api_bom.class.php rename to htdocs/bom/class/api_boms.class.php index 4d13475be1a..adda9ceb238 100644 --- a/htdocs/bom/class/api_bom.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -18,12 +18,11 @@ use Luracast\Restler\RestException; -dol_include_once('/bom/class/bom.class.php'); - +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; /** - * \file bom/class/api_bom.class.php + * \file bom/class/api_boms.class.php * \ingroup bom * \brief File for API management of bom. */ @@ -31,36 +30,32 @@ dol_include_once('/bom/class/bom.class.php'); /** * API class for bom bom * - * @smart-auto-routing false * @access protected * @class DolibarrApiAccess {@requires user,external} */ -class BillOfMaterialsApi extends DolibarrApi +class BOMs extends DolibarrApi { /** * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( - 'name', + 'label' ); /** - * @var BillOfMaterials $bom {@type BillOfMaterials} + * @var BOM $bom {@type BOM} */ public $bom; /** * Constructor - * - * @url GET / - * */ public function __construct() { global $db, $conf; $this->db = $db; - $this->bom = new BillOfMaterials($this->db); + $this->bom = new BOM($this->db); } /** @@ -71,7 +66,7 @@ class BillOfMaterialsApi extends DolibarrApi * @param int $id ID of bom * @return array|mixed data without useless information * - * @url GET boms/{id} + * @url GET {id} * @throws RestException */ public function get($id) @@ -82,7 +77,7 @@ class BillOfMaterialsApi extends DolibarrApi $result = $this->bom->fetch($id); if( ! $result ) { - throw new RestException(404, 'BillOfMaterials not found'); + throw new RestException(404, 'BOM not found'); } if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { @@ -106,8 +101,6 @@ class BillOfMaterialsApi extends DolibarrApi * @return array Array of order objects * * @throws RestException - * - * @url GET /boms/ */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { @@ -134,7 +127,7 @@ class BillOfMaterialsApi extends DolibarrApi //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $tmpobject = new BillOfMaterials($db); + $tmpobject = new BOM($db); if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')'; if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; @@ -172,7 +165,7 @@ class BillOfMaterialsApi extends DolibarrApi while ($i < $num) { $obj = $db->fetch_object($result); - $bom_static = new BillOfMaterials($db); + $bom_static = new BOM($db); if($bom_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($bom_static); } @@ -193,8 +186,6 @@ class BillOfMaterialsApi extends DolibarrApi * * @param array $request_data Request datas * @return int ID of bom - * - * @url POST boms/ */ public function post($request_data = null) { @@ -208,7 +199,7 @@ class BillOfMaterialsApi extends DolibarrApi $this->bom->$field = $value; } if( ! $this->bom->create(DolibarrApiAccess::$user)) { - throw new RestException(500); + throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors)); } return $this->bom->id; } @@ -218,9 +209,8 @@ class BillOfMaterialsApi extends DolibarrApi * * @param int $id Id of bom to update * @param array $request_data Datas - * @return int * - * @url PUT boms/{id} + * @return int */ public function put($id, $request_data = null) { @@ -230,7 +220,7 @@ class BillOfMaterialsApi extends DolibarrApi $result = $this->bom->fetch($id); if( ! $result ) { - throw new RestException(404, 'BillOfMaterials not found'); + throw new RestException(404, 'BOM not found'); } if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { @@ -238,46 +228,49 @@ class BillOfMaterialsApi extends DolibarrApi } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->bom->$field = $value; } - if($this->bom->update($id, DolibarrApiAccess::$user)) + if($this->bom->update($id, DolibarrApiAccess::$user) > 0) + { return $this->get($id); - - return false; + } + else + { + throw new RestException(500, $this->commande->error); + } } /** * Delete bom * - * @param int $id BillOfMaterials ID + * @param int $id BOM ID * @return array - * - * @url DELETE bom/{id} */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->bom->delete) { + if (! DolibarrApiAccess::$user->rights->bom->delete) { throw new RestException(401); } $result = $this->bom->fetch($id); - if( ! $result ) { - throw new RestException(404, 'BillOfMaterials not found'); + if (! $result) { + throw new RestException(404, 'BOM not found'); } - if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { + if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->bom->delete(DolibarrApiAccess::$user, 0)) + if (! $this->bom->delete(DolibarrApiAccess::$user)) { - throw new RestException(500); + throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error); } return array( 'success' => array( 'code' => 200, - 'message' => 'BillOfMaterials deleted' + 'message' => 'BOM deleted' ) ); } @@ -287,8 +280,8 @@ class BillOfMaterialsApi extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param object $object Object to clean + * @return array Array of cleaned object properties */ protected function _cleanObjectDatas($object) { @@ -308,15 +301,15 @@ class BillOfMaterialsApi extends DolibarrApi /** * Validate fields before create or update object * - * @param array $data Data to validate - * @return array + * @param array $data Array of data to validate + * @return array * - * @throws RestException + * @throws RestException */ private function _validate($data) { $bom = array(); - foreach (BillOfMaterialsApi::$FIELDS as $field) { + foreach (BOMs::$FIELDS as $field) { if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $bom[$field] = $data[$field]; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 24508d6fb11..ca7823a6ac1 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -16,9 +16,9 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; /** * API class for orders @@ -544,7 +544,7 @@ class Orders extends DolibarrApi } if( ! $this->commande->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete order : '.$this->commande->error); + throw new RestException(500, 'Error when deleting order : '.$this->commande->error); } return array( diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 566fe56affb..acf7f65454d 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -31,7 +31,6 @@ dol_include_once('/mymodule/class/myobject.class.php'); /** * API class for mymodule myobject * - * @smart-auto-routing false * @access protected * @class DolibarrApiAccess {@requires user,external} */ @@ -205,7 +204,7 @@ class MyModuleApi extends DolibarrApi $this->myobject->$field = $value; } if( ! $this->myobject->create(DolibarrApiAccess::$user)) { - throw new RestException(500); + throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors)); } return $this->myobject->id; } @@ -235,13 +234,18 @@ class MyModuleApi extends DolibarrApi } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->myobject->$field = $value; } - if($this->myobject->update($id, DolibarrApiAccess::$user)) + if ($this->myobject->update($id, DolibarrApiAccess::$user) > 0) + { return $this->get($id); - - return false; + } + else + { + throw new RestException(500, $this->myobject->error); + } } /** @@ -254,21 +258,21 @@ class MyModuleApi extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->myobject->delete) { + if (! DolibarrApiAccess::$user->rights->myobject->delete) { throw new RestException(401); } $result = $this->myobject->fetch($id); - if( ! $result ) { + if (! $result) { throw new RestException(404, 'MyObject not found'); } - if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { + if (! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) + if (! $this->myobject->delete(DolibarrApiAccess::$user)) { - throw new RestException(500); + throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error); } return array( @@ -305,10 +309,10 @@ class MyModuleApi extends DolibarrApi /** * Validate fields before create or update object * - * @param array $data Data to validate - * @return array + * @param array $data Array of data to validate + * @return array * - * @throws RestException + * @throws RestException */ private function _validate($data) { From 8246c79b15fa039a79c0e48af63b734d6bcfc2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:20:44 +0100 Subject: [PATCH 67/99] Update bom_card.php --- htdocs/bom/bom_card.php | 45 ++++++----------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 0054e427996..28deae35d86 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2019 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 @@ -17,50 +17,17 @@ */ /** - * \file bom_card.php + * \file htdocs/bom/bom_card.php * \ingroup bom * \brief Page to create/edit/view bom */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies - - // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/bom/class/bom.class.php'); -dol_include_once('/bom/lib/bom_bom.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php'; // Load translation files required by the page $langs->loadLangs(array("mrp","other")); From 6067994119a42eb355cba41f61ec5e458e77fb71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:23:25 +0100 Subject: [PATCH 68/99] Update bom_document.php --- htdocs/bom/bom_document.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index b13277cd82b..ff8887bb4e8 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2007-2017 Laurent Destailleur + * Copyright (C) 2019 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 @@ -23,26 +23,13 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - +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.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/bom/class/bom.class.php'); -dol_include_once('/bom/lib/bom_bom.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php'; // Load translation files required by the page $langs->loadLangs(array("mrp","companies","other","mails")); From e4de89e3eb17ec315f5802c191fa2c4576109235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:25:02 +0100 Subject: [PATCH 69/99] Update bom_list.php --- htdocs/bom/bom_list.php | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 25fad036b65..6aec37c5f2c 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -17,49 +17,16 @@ */ /** - * \file bom_list.php + * \file htdocs/bom/bom_list.php * \ingroup bom * \brief List page for bom */ - -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' - // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -dol_include_once('/bom/class/bom.class.php'); +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; // Load translation files required by the page $langs->loadLangs(array("mrp", "other")); From cf00b2a2df5e69b84261e6253826415bbb52ad7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:26:23 +0100 Subject: [PATCH 70/99] Update bom_note.php --- htdocs/bom/bom_note.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index fb0d58509d7..4c45512c064 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2007-2017 Laurent Destailleur + * Copyright (C) 2019 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 @@ -23,22 +23,9 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - -dol_include_once('/bom/class/bom.class.php'); -dol_include_once('/bom/lib/bom_bom.lib.php'); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php'; // Load translation files required by the page $langs->loadLangs(array("mrp","companies")); From 02d4a234b71b3fd07279c971adc698aada23c8e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:30:34 +0100 Subject: [PATCH 71/99] Update bom.lib.php --- htdocs/bom/lib/bom.lib.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 0085d06b69c..98f5370217e 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2019 Maxime Kohlhaas + * Copyright (C) 2019 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 @@ -16,7 +17,7 @@ */ /** - * \file bom/lib/bom.lib.php + * \file htdocs/bom/lib/bom.lib.php * \ingroup bom * \brief Library files with common functions for BillOfMaterials */ @@ -40,7 +41,7 @@ function bomAdminPrepareHead() $head[$h][2] = 'settings'; $h++; - /*$head[$h][0] = dol_buildpath("/bom/admin/about.php", 1); + /*$head[$h][0] = DOL_URL_ROOT."/bom/admin/about.php"; $head[$h][1] = $langs->trans("About"); $head[$h][2] = 'about'; $h++; @@ -77,7 +78,7 @@ function bomPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/bom/bom_card.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT."/bom/bom_card.php?id=".$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -87,7 +88,7 @@ function bomPrepareHead($object) $nbNote = 0; if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_public)) $nbNote++; - $head[$h][0] = dol_buildpath('/bom/bom_note.php', 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id=".$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; @@ -99,13 +100,13 @@ function bomPrepareHead($object) $upload_dir = $conf->bom->dir_output . "/bom/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); - $head[$h][0] = dol_buildpath("/bom/bom_document.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT."/bom/bom_document.php?id=".$object->id; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; $head[$h][2] = 'document'; $h++; - $head[$h][0] = dol_buildpath("/bom/bom_agenda.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT."/bom/bom_agenda.php?id=".$object->id; $head[$h][1] = $langs->trans("Events"); $head[$h][2] = 'agenda'; $h++; From e57a67493905f7c050d0886f849d3b61ca7aa517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:36:48 +0100 Subject: [PATCH 72/99] Update setup.php --- htdocs/bom/admin/setup.php | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php index 561b44fa262..a484718ac32 100644 --- a/htdocs/bom/admin/setup.php +++ b/htdocs/bom/admin/setup.php @@ -1,6 +1,7 @@ - * Copyright (C) 2019 Maxime Kohlhaas +/* Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2019 Maxime Kohlhaas + * Copyright (C) 2019 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 @@ -23,21 +24,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - -global $langs, $user; - +require '../../main.inc.php'; // Libraries require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; require_once '../lib/bom.lib.php'; @@ -62,11 +49,7 @@ $arrayofparameters=array( /* * Actions */ -if ((float) DOL_VERSION >= 6) -{ - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} - +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; /* * View From 2185f129cd3b78007f5b95ee49acf8340b94c99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:44:03 +0100 Subject: [PATCH 73/99] syntax error --- htdocs/bom/lib/bom.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 98f5370217e..20f9fccfb01 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -88,7 +88,7 @@ function bomPrepareHead($object) $nbNote = 0; if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id=".$object->id; + $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; @@ -100,13 +100,13 @@ function bomPrepareHead($object) $upload_dir = $conf->bom->dir_output . "/bom/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT."/bom/bom_document.php?id=".$object->id; + $head[$h][0] = DOL_URL_ROOT.'/bom/bom_document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; $head[$h][2] = 'document'; $h++; - $head[$h][0] = DOL_URL_ROOT."/bom/bom_agenda.php?id=".$object->id; + $head[$h][0] = DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); $head[$h][2] = 'agenda'; $h++; From 9e6a5a0b8171ae83215b14cae07b57f889c971e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 18:49:03 +0100 Subject: [PATCH 74/99] Update eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 04f379b746f..1db6dc01ab4 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 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 @@ -65,6 +65,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } + $menu_arr = array(); // Home $menu_arr[] = array( 'name' => 'Home', From edf9913c20c5d606fe545145c772384d23ebff1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 19:00:12 +0100 Subject: [PATCH 75/99] Update bom_list.php --- htdocs/bom/bom_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 6aec37c5f2c..cf9ad7ffaf2 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -56,7 +56,7 @@ $pagenext = $page + 1; //if (! $sortorder) $sortorder="DESC"; // Initialize technical objects -$object = new BillOfMaterials($db); +$object = new BOM($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array @@ -146,7 +146,7 @@ if (empty($reshook)) } // Mass actions - $objectclass='BillOfMaterials'; + $objectclass='BOM'; $objectlabel='BillOfMaterials'; $permtoread = $user->rights->bom->read; $permtodelete = $user->rights->bom->delete; From 7b0956297636057d4f976ebc96722c3f20884b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 19:05:13 +0100 Subject: [PATCH 76/99] Update bom_card.php --- htdocs/bom/bom_card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 28deae35d86..19d7fdaa60b 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -42,7 +42,7 @@ $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomcard $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new BillOfMaterials($db); +$object=new BOM($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -86,10 +86,10 @@ if (empty($reshook)) $permissiontoadd = $user->rights->bom->write; $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); - $backurlforlist = dol_buildpath('/bom/bom_list.php', 1); + $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; if (empty($backtopage)) { if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/bom/bom_card.php', 1).($id > 0 ? $id : '__ID__'); + else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.$id; } $triggermodname = 'BILLOFMATERIALS_BILLOFMATERIALS_MODIFY'; // Name of trigger action code to execute when we modify record From e163849d05ec8f28c64bdc94f4cb9cb04f80b71e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 19:13:59 +0100 Subject: [PATCH 77/99] Fix label --- htdocs/langs/en_US/blockedlog.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 5081b1c0384..9e8771ad68b 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -14,9 +14,9 @@ OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to prev AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority ShowDetails=Show stored details -logPAYMENT_VARIOUS_CREATE=Payment (not assigned to invoice) created -logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to invoice) modified -logPAYMENT_VARIOUS_DELETE=Payment (not assigned to invoice) logical deletion +logPAYMENT_VARIOUS_CREATE=Payment (not assigned to an invoice) created +logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to an invoice) modified +logPAYMENT_VARIOUS_DELETE=Payment (not assigned to an invoice) logical deletion logPAYMENT_ADD_TO_BANK=Payment added to bank logPAYMENT_CUSTOMER_CREATE=Customer payment created logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion From 31c296f44b795503858b9aa26682b05f6dd29430 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 20:01:21 +0100 Subject: [PATCH 78/99] Fix bad tooltip to rm file --- htdocs/admin/system/filecheck.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index ba8307792fc..f00164698e8 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -339,8 +339,8 @@ if (! $error && $xml) $out.=''.$i.'' . "\n"; $out.=''.$file['filename']; 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'); + $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); } $out.='' . "\n"; $out.=''.$file['expectedmd5'].'' . "\n"; From d39b600ff4cd6eb4b702fef71899e38dffe67837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Mar 2019 20:29:58 +0100 Subject: [PATCH 79/99] Update CMailFile.class.php --- htdocs/core/class/CMailFile.class.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index e23b32c5fb7..3c0e979cbed 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1,11 +1,12 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) Dan Potter + * Copyright (C) Eric Seigne + * Copyright (C) 2000-2005 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2019 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 @@ -1429,7 +1430,7 @@ class CMailFile * Return a formatted address string for SMTP protocol * * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' - * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between " + * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between ", 4 label or email, 5 mailto link * @param int $encode 0=No encode name, 1=Encode name to RFC2822 * @param int $maxnumberofemail 0=No limit. Otherwise, maximum number of emails returned ($address may contains several email separated with ','). Add '...' if there is more. * @return string If format 0: '' or 'John Doe ' or '=?UTF-8?B?Sm9obiBEb2U=?= ' @@ -1437,6 +1438,7 @@ class CMailFile * If format 2: 'john@doe.com' * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists + * If format 5: John Doe or john@doe.com if no label exists */ public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { @@ -1466,6 +1468,10 @@ class CMailFile $i++; $newemail=''; + if ($format == 5) { + $newemail = $name?$name:$email; + $newemail = ''.$newemail.''; + } if ($format == 4) { $newemail = $name?$name:$email; From 1b0aec0847732d58da4a719afec45f7e99d14cf0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 20:51:07 +0100 Subject: [PATCH 80/99] Complete fields for template invoices --- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 7 +++++++ htdocs/install/mysql/tables/llx_facturedet.sql | 8 ++++---- htdocs/install/mysql/tables/llx_facturedet_rec.sql | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 5154d7311a9..7dd893b8dab 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -230,3 +230,10 @@ ALTER TABLE llx_bom_bom ADD INDEX idx_bom_bom_fk_product (fk_product); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_rowid (rowid); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_product (fk_product); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom); + +ALTER TABLE llx_facturedet_rec ADD COLUMN buy_price_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_facturedet_rec ADD COLUMN fk_product_fournisseur_price integer DEFAULT NULL; + +ALTER TABLE llx_facturedet_rec ADD COLUMN fk_user_author integer; +ALTER TABLE llx_facturedet_rec ADD COLUMN fk_user_modif integer; + diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index ac7142c898d..deb52576a8a 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -55,16 +55,16 @@ create table llx_facturedet buy_price_ht double(24,8) DEFAULT 0, -- buying price. Note: this value is saved as an always positive value, even on credit notes (it is price we bought the product before selling it). fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) - fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line - special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...) rang integer DEFAULT 0, -- position of line fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines + fk_unit integer DEFAULT NULL, -- id of the unit code import_key varchar(14), + fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line + situation_percent real, -- % progression of lines invoicing - fk_prev_id integer, -- id of the line in the previous situation, - fk_unit integer DEFAULT NULL, -- id of the unit code¡ + fk_prev_id integer, -- id of the line in the previous situation fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change diff --git a/htdocs/install/mysql/tables/llx_facturedet_rec.sql b/htdocs/install/mysql/tables/llx_facturedet_rec.sql index ac79dfd891d..267abcd5053 100644 --- a/htdocs/install/mysql/tables/llx_facturedet_rec.sql +++ b/htdocs/install/mysql/tables/llx_facturedet_rec.sql @@ -48,11 +48,18 @@ create table llx_facturedet_rec date_start_fill integer DEFAULT 0, -- 1=autofill the date_start of invoice with __INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__ date_end_fill integer DEFAULT 0, -- 1=autofill the date_start of invoice with __INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__ info_bits integer DEFAULT 0, -- TVA NPR ou non + + buy_price_ht double(24,8) DEFAULT 0, -- buying price. Note: this value is saved as an always positive value, even on credit notes (it is price we bought the product before selling it). + fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) + special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- ordre d'affichage fk_contract_line integer NULL, -- id of contract line when template invoice comes from contract lines fk_unit integer DEFAULT NULL, import_key varchar(14), + + fk_user_author integer, -- user making creation + fk_user_modif integer, -- user making last change fk_multicurrency integer, multicurrency_code varchar(255), From b15e00cae798c8792a7b5c7aef104bdfa94f665b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 21:39:09 +0100 Subject: [PATCH 81/99] FIX Autodetect buy price for invoices autogenerated with templates. --- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 31 +++++++++++++++++-- htdocs/product/class/product.class.php | 7 +++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1df96583ce3..e37d2c3d2a9 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1129,7 +1129,7 @@ if (empty($reshook)) // Source facture $object->fac_rec = GETPOST('fac_rec', 'int'); - $id = $object->create($user); // This include recopy of links from recurring invoice and invoice lines + $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index dda877d0a1f..86ee5482261 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -723,7 +723,7 @@ class Facture extends CommonInvoice } /* - * Insert lines of predefined invoices + * Insert lines of template invoices */ if (! $error && $this->fac_rec > 0) { @@ -749,6 +749,31 @@ class Facture extends CommonInvoice $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; + $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price)?null:$_facrec->lines[$i]->fk_product_fournisseur_price; + $buyprice = empty($_facrec->lines[$i]->buyprice)?0:$_facrec->lines[$i]->buyprice; + // If buyprice not defined from template invoice, we try to guess the best value + if (! $buyprice && $_facrec->lines[$i]->fk_product > 0) + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $producttmp = new ProductFournisseur($this->db); + $producttmp->fetch($_facrec->lines[$i]->fk_product); + + // If margin module defined on costprice, we try the costprice + // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price + // else we get the best supplier price + if ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; + elseif (! empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && ! empty($producttmp->pmp)) $buyprice = $producttmp->pmp; + else { + if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) + { + if ($producttmp->product_fourn_price_id > 0) + { + $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent/100) + $producttmp->fourn_remise, 'MU'); + } + } + } + } + $result_insert = $this->addline( $_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, @@ -771,8 +796,8 @@ class Facture extends CommonInvoice '', 0, 0, - null, - 0, + $fk_product_fournisseur_price, + $buyprice, $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 316a911d5a3..88b410da7fa 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1528,8 +1528,8 @@ class Product extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Read price used by a provider. - * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. + * Read price used by a provider. + * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. * This also set some properties on product like ->buyprice, ->fourn_pu, ... * * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price @@ -1537,7 +1537,8 @@ class Product extends CommonObject * @param int $product_id Filter on a particular product id * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. * @param int $fk_soc If of supplier - * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) + * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) + * @see find_min_price_product_fournisseur() */ function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_soc=0) { From 96b8da0d6247fd0d12f77f71ba664e2dc485dee2 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 22:04:01 +0100 Subject: [PATCH 82/99] fix supllier discount --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 61818d4deb9..d598c18a33e 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -268,7 +268,7 @@ else { } else { - $ajaxoptions = array(); + $ajaxoptions = array('update' => array('remise_percent' => 'discount')); $alsoproductwithnosupplierprice=1; } From c31318f29d36e41cb3a24d97bcab641d1ea99a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timote=CC=81=20Fallais?= Date: Thu, 7 Mar 2019 09:15:43 +0100 Subject: [PATCH 83/99] Update libelle of user (making Mailman working correctly) --- htdocs/adherents/class/adherent.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 688b2c9741a..15cb81f8474 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -563,6 +563,18 @@ class Adherent extends CommonObject $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest $sql.= " WHERE rowid = ".$this->id; + $sql2 = "SELECT libelle"; + $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql2.= " WHERE rowid = ".$this->typeid; + $resql2 = $this->db->query($sql2); + if($resql2) + { + while ($obj=$this->db->fetch_object($resql2)) + { + $this->type=$obj->libelle; + } + } + dol_syslog(get_class($this)."::update update member", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) From c5131167171cd9c1f977599c47ea18fc88e5f722 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 10:56:48 +0100 Subject: [PATCH 84/99] FIX missing vat_src_code when inserting an expense report line --- htdocs/expensereport/class/expensereport.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index a8e5f80244c..dd2818f28bf 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1729,6 +1729,7 @@ class ExpenseReport extends CommonObject $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller, $localtaxes_type); $this->line->value_unit = $up; + $this->line->vat_src_code = $vat_src_code; $this->line->vatrate = price2num($vatrate); $this->line->total_ttc = $tmp[2]; $this->line->total_ht = $tmp[0]; From 2cd09aaf0929181894da2660e46e3deed8df9901 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 10:57:15 +0100 Subject: [PATCH 85/99] Prepare version 9.0.2 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index b2213c5d03c..03f949c6fe6 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.2'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 96d4e2847324d093a1fd7709ea637ef0f750e8a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 11:08:01 +0100 Subject: [PATCH 86/99] FIX Vat src code lost after editing expense report line --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index eb71a30e083..fab70b1200a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2137,7 +2137,7 @@ else // VAT print ''; - print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, ''); + print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); print ''; // Unit price From e67890bd22037d5ee077d850a07df7ab9b6035c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 11:09:04 +0100 Subject: [PATCH 87/99] NEW Can enter price with or without tax when entering expense repor line --- htdocs/admin/dict.php | 2 +- htdocs/expensereport/card.php | 121 ++++++++++++------ .../class/expensereport.class.php | 24 ++-- .../install/mysql/migration/9.0.0-10.0.0.sql | 3 + .../mysql/tables/llx_expensereport_det.sql | 3 +- 5 files changed, 100 insertions(+), 53 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 11134f70194..541262b2bf5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1912,7 +1912,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { - print ''; + print ''; } elseif ($fieldlist[$field]=='unit') { print ''; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 2ce6ca0f70a..3c7253f9065 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -133,6 +133,7 @@ if (empty($reshook)) $date=''; $comments=''; $vatrate=''; + $value_unit_ht=''; $value_unit=''; $qty=1; $fk_c_type_fees=-1; @@ -1095,10 +1096,16 @@ if (empty($reshook)) // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. if (empty($vatrate)) $vatrate = "0.000"; - $vatrate = price2num($vatrate); + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate)); + $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); $value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU'); - $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); + if (empty($value_unit)) + { + $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU'); + } + + $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); $qty = GETPOST('qty', 'int'); if (empty($qty)) $qty=1; @@ -1110,23 +1117,13 @@ if (empty($reshook)) $action=''; } - if ($vatrate < 0 || $vatrate == '') + if ((int) $tmpvat < 0 || $tmpvat == '') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors'); $action=''; } - /* Projects are never required. To force them, check module forceproject - if ($conf->projet->enabled) - { - if (empty($object_ligne->fk_projet) || $object_ligne->fk_projet==-1) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors'); - } - }*/ - // Si aucune date n'est rentrée if (empty($date) || $date=="--") { @@ -1134,7 +1131,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } // Si aucun prix n'est rentré - if ($value_unit==0) + if ($value_unit == 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors'); @@ -1171,6 +1168,7 @@ if (empty($reshook)) } unset($qty); + unset($value_unit_ht); unset($value_unit); unset($vatrate); unset($comments); @@ -1240,12 +1238,18 @@ if (empty($reshook)) $projet_id = $fk_projet; $comments = GETPOST('comments', 'none'); $qty = GETPOST('qty', 'int'); - $value_unit = price2num(GETPOST('value_unit', 'alpha'), 'MU'); $vatrate = GETPOST('vatrate', 'alpha'); - // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. - if (empty($vatrate)) $vatrate = "0.000"; - $vatrate = price2num($vatrate); + // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. + if (empty($vatrate)) $vatrate = "0.000"; + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate)); + + $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); + $value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU'); + if (empty($value_unit)) + { + $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU'); + } if (! GETPOST('fk_c_type_fees', 'int') > 0) { @@ -1253,7 +1257,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $action=''; } - if ((int) $vatrate < 0 || $vatrate == '') + if ((int) $tmpvat < 0 || $tmpvat == '') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors'); @@ -1742,7 +1746,7 @@ else print ''; // User to inform for approval - if ($object->fk_statut < 3) // informed + if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) // informed { print ''; print ''.$langs->trans("VALIDATOR").''; // approver @@ -1760,7 +1764,7 @@ else } print ''; } - elseif($object->fk_statut == 4) + elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED) { print ''; print ''.$langs->trans("CANCEL_USER").''; @@ -1854,11 +1858,11 @@ else print ''.$langs->trans("AmountHT").''; print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).''; $rowspan = 5; - if ($object->fk_statut < 3) $rowspan++; - elseif($object->fk_statut == 4) $rowspan+=2; + if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) $rowspan++; + elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan+=2; else $rowspan+=2; - if ($object->fk_statut==99 || !empty($object->detail_refuse)) $rowspan+=2; - if($object->fk_statut==6) $rowspan+=2; + if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan+=2; + if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan+=2; print ""; print ''; @@ -2016,6 +2020,7 @@ else print ''.$langs->trans('Type').''; print ''.$langs->trans('Description').''; print ''.$langs->trans('VAT').''; + print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('PriceUTTC').''; print ''.$langs->trans('Qty').''; if ($action != 'editline') @@ -2071,6 +2076,7 @@ else print ''; print ''.dol_escape_htmltag($line->comments).''; print ''.vatrate($line->vatrate, true).''; + print ''.price($line->value_unit_ht).''; print ''.price($line->value_unit).''; print ''.dol_escape_htmltag($line->qty).''; @@ -2081,7 +2087,7 @@ else } // Ajout des boutons de modification/suppression - if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer) + if (($object->fk_statut < ExpenseReport::STATUS_VALIDATED || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) { print ''; @@ -2137,12 +2143,17 @@ else // VAT print ''; - print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, ''); + print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); print ''; // Unit price print ''; - print ''; + print ''; + print ''; + + // Unit price with tax + print ''; + print ''; print ''; // Quantity @@ -2178,6 +2189,7 @@ else print ''.$langs->trans('Type').''; print ''.$langs->trans('Description').''; print ''.$langs->trans('VAT').''; + print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('PriceUTTC').''; print ''.$langs->trans('Qty').''; print ''; @@ -2225,9 +2237,14 @@ else print $form->load_tva('vatrate', ($vatrate!=''?$vatrate:$defaultvat), $mysoc, '', 0, 0, '', false, 1); print ''; - // Unit price + // Unit price net print ''; - print ''; + print ''; + print ''; + + // Unit price with tax + print ''; + print ''; print ''; // Quantity @@ -2249,6 +2266,26 @@ else print ''; print ''; + print ''; + print ''; dol_fiche_end(); @@ -2286,7 +2323,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if ($user->rights->expensereport->creer && $object->fk_statut==0) + if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_DRAFT) { if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) { @@ -2306,7 +2343,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if($user->rights->expensereport->creer && $object->fk_statut==99) + if($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -2320,7 +2357,7 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->to_paid && $object->fk_statut==5) + if ($user->rights->expensereport->to_paid && $object->fk_statut == ExpenseReport::STATUS_APPROVED) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -2334,7 +2371,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_validator == user courant * Afficher : "Valider" / "Refuser" / "Supprimer" */ - if ($object->fk_statut == 2) + if ($object->fk_statut == ExpenseReport::STATUS_VALIDATED) { if (in_array($object->fk_user_author, $user->getAllChildIds(1))) { @@ -2343,7 +2380,7 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->approve && $object->fk_statut == 2) + if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_VALIDATED) { //if($object->fk_user_validator==$user->id) //{ @@ -2364,13 +2401,13 @@ if ($action != 'create' && $action != 'edit') // If status is Appoved // -------------------- - if ($user->rights->expensereport->approve && $object->fk_statut == 5) + if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_APPROVED) { print ''; } // If bank module is used - if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == 5) + if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) { // Pay if ($remaintopay == 0) @@ -2384,7 +2421,7 @@ if ($action != 'create' && $action != 'edit') } // If bank module is not used - if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5) + if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) { //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) if ($object->paid == 0) @@ -2393,14 +2430,14 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == 5) + if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) { // Cancel print ''; } // TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled. - if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == 6) + if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == ExpenseReport::STATUS_CLOSED) { // Cancel print ''; @@ -2412,12 +2449,12 @@ if ($action != 'create' && $action != 'edit') } /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ - if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut <= 4) + if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut < ExpenseReport::STATUS_APPROVED) { // Delete print ''; } - elseif($user->rights->expensereport->supprimer && $object->fk_statut != 6) + elseif($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED) { // Delete print ''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index bbada0e22f7..dc0ffefe4ff 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -115,6 +115,11 @@ class ExpenseReport extends CommonObject */ const STATUS_VALIDATED = 2; + /** + * Classified canceled + */ + const STATUS_CANCELED = 4; + /** * Classified approved */ @@ -1442,12 +1447,12 @@ class ExpenseReport extends CommonObject // phpcs:enable $error = 0; $this->date_cancel = $this->db->idate(gmmktime()); - if ($this->fk_statut != 4) + if ($this->fk_statut != ExpenseReport::STATUS_CANCELED) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_statut = 4, fk_user_cancel = ".$fuser->id; + $sql.= " SET fk_statut = ".ExpenseReport::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; $sql.= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; $sql.= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql.= ' WHERE rowid = '.$this->id; @@ -1676,10 +1681,10 @@ class ExpenseReport extends CommonObject /** * addline * - * @param real $qty Qty + * @param float $qty Qty * @param double $up Value init * @param int $fk_c_type_fees Type payment - * @param double $vatrate Vat rate + * @param string $vatrate Vat rate (Can be '10' or '10 (ABC)') * @param string $date Date * @param string $comments Description * @param int $fk_project Project id @@ -1703,8 +1708,8 @@ class ExpenseReport extends CommonObject if (empty($fk_project)) $fk_project = 0; $qty = price2num($qty); - if (!preg_match('/\((.*)\)/', $vatrate)) { - $vatrate = price2num($vatrate); // $txtva can have format '5.0(XXX)' or '5' + if (! preg_match('/\s*\((.*)\)/', $vatrate)) { + $vatrate = price2num($vatrate); // $txtva can have format '5.0 (XXX)' or '5' } $up = price2num($up); @@ -1715,7 +1720,7 @@ class ExpenseReport extends CommonObject $localtaxes_type=getLocalTaxesFromRate($vatrate, 0, $mysoc, $this->thirdparty); $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $vatrate, $reg)) + if (preg_match('/\s*\((.*)\)/', $vatrate, $reg)) { $vat_src_code = $reg[1]; $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. @@ -1727,6 +1732,7 @@ class ExpenseReport extends CommonObject $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller, $localtaxes_type); $this->line->value_unit = $up; + $this->line->vat_src_code = $vat_src_code; $this->line->vatrate = price2num($vatrate); $this->line->total_ttc = $tmp[2]; $this->line->total_ht = $tmp[0]; @@ -1928,9 +1934,9 @@ class ExpenseReport extends CommonObject * @param int $rowid Line to edit * @param int $type_fees_id Type payment * @param int $projet_id Project id - * @param double $vatrate Vat rate. Can be '8.5* (8.5NPROM...)' + * @param double $vatrate Vat rate. Can be '8.5' or '8.5* (8.5NPROM...)' * @param string $comments Description - * @param real $qty Qty + * @param float $qty Qty * @param double $value_unit Value init * @param int $date Date * @param int $expensereport_id Expense report id diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 7dd893b8dab..72330e09b92 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -237,3 +237,6 @@ ALTER TABLE llx_facturedet_rec ADD COLUMN fk_product_fournisseur_price integer D ALTER TABLE llx_facturedet_rec ADD COLUMN fk_user_author integer; ALTER TABLE llx_facturedet_rec ADD COLUMN fk_user_modif integer; +ALTER TABLE llx_expensereport_det MODIFY COLUMN value_unit double(24,8) NOT NULL; +ALTER TABLE llx_expensereport_det ADD COLUMN subprice double(24,8) NOT NULL after qty; + diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index fc0bd6e697f..1000e10955f 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -27,7 +27,8 @@ CREATE TABLE llx_expensereport_det comments text NOT NULL, product_type integer DEFAULT -1, qty real NOT NULL, - value_unit real NOT NULL, + subprice double(24,8), -- P.U. HT (example 100) + value_unit double(24,8) NOT NULL, -- P.U. TTC (example 120) remise_percent real, vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- Vat rate From a6bb1cf5f6dc33e473eaca7adff899197c251f76 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 7 Mar 2019 11:27:06 +0100 Subject: [PATCH 88/99] avoid timeout --- htdocs/core/modules/export/export_csv.modules.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 249d1563988..5bdc2f384ac 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -24,6 +24,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php'; +// avoid timeout for big export +set_time_limit(0); /** * Class to build export files with format CSV From f54eb78260a58b414961c3cc13afcd201bebf7a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 12:22:24 +0100 Subject: [PATCH 89/99] NEW Show the latest date of subscription in member statistics reports --- htdocs/adherents/stats/byproperties.php | 16 ++++---- htdocs/adherents/stats/geo.php | 37 ++++++++++++------- .../install/mysql/migration/9.0.0-10.0.0.sql | 2 + htdocs/langs/en_US/users.lang | 2 +- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 164606431ff..6ba88e7771b 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -58,15 +58,16 @@ llxHeader('', $langs->trans("MembersStatisticsByProperties"), '', '', 0, 0, arra $title=$langs->trans("MembersStatisticsByProperties"); -print load_fiche_titre($title, $mesg); +print load_fiche_titre($title, ''); dol_mkdir($dir); $tab='byproperties'; $data = array(); -$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code"; +$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; +$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY d.morphy"; @@ -87,7 +88,7 @@ if ($resql) if ($obj->code == 'phy') $foundphy++; if ($obj->code == 'mor') $foundmor++; - $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate)); + $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); $i++; } @@ -120,22 +121,21 @@ print ''; print ''; print ''; print ''; +print ''; print ''; print ''; -if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>''); -if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>''); +if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>''); +if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>''); -$oldyear=0; foreach ($data as $val) { - $year = $val['year']; print ''; print ''; print ''; print ''; + print ''; print ''; - $oldyear=$year; } print '
'.$langs->trans("Nature").''.$langs->trans("NbOfMembers").''.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$memberstatic->getmorphylib($val['label']).''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index f5816f46aca..79aa5ab6a82 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -77,8 +77,10 @@ if ($mode) $tab='statscountry'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label"; - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; + $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code"; @@ -92,10 +94,12 @@ if ($mode) $tab='statsstate'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, c.nom as label2"; // - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // + $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, c.nom"; @@ -108,10 +112,12 @@ if ($mode) $tab='statsregion'; //onglet $data = array(); //tableau de donnée - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, r.nom as label2"; - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; + $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, r.nom"; //+ @@ -124,9 +130,10 @@ if ($mode) $tab='statstown'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code, d.town"; @@ -154,7 +161,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'code'=>$obj->code, 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbyregion') //+ @@ -164,7 +172,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbystate') @@ -173,7 +182,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbytown') @@ -182,7 +192,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } @@ -289,9 +300,9 @@ if ($mode) if ($label2) print ''.$label2.''; print ''.$langs->trans("NbOfMembers").''; print ''.$langs->trans("LastMemberDate").''; + print ''.$langs->trans("LatestSubscriptionDate").''; print ''; - $oldyear=0; foreach ($data as $val) { $year = $val['year']; @@ -300,8 +311,8 @@ if ($mode) if ($label2) print ''.$val['label2'].''; print ''.$val['nb'].''; print ''.dol_print_date($val['lastdate'], 'dayhour').''; + print ''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').''; print ''; - $oldyear=$year; } print ''; diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 72330e09b92..19c6d2b386c 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -58,6 +58,8 @@ CREATE TABLE llx_pos_cash_fence( -- For 10.0 +DROP TABLE llx_cotisation; + ALTER TABLE llx_loan ADD COLUMN insurance_amount double(24,8) DEFAULT 0; ALTER TABLE llx_facture DROP INDEX idx_facture_uk_facnumber; diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 53ac720d862..fb35cb5e112 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -109,4 +109,4 @@ UserLogoff=User logout UserLogged=User logged DateEmployment=Employment Start Date DateEmploymentEnd=Employment End Date -CantDisableYourself=You can disable your own user record \ No newline at end of file +CantDisableYourself=You can't disable your own user record \ No newline at end of file From e3fb228a4d148265945c5a0008019f9534b18221 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 12:28:19 +0100 Subject: [PATCH 90/99] Update fournisseur.facture.class.php --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b0351252c0b..4642c0bf753 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1481,7 +1481,7 @@ class FactureFournisseur extends CommonInvoice $this->line->total_localtax1=$total_localtax1; $this->line->total_localtax2=$total_localtax2; $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); - $this->line->special_code=!empty($special_code) ? $special_code : $this->special_code; + $this->line->special_code=((string) $special_code != '' ? $special_code : $this->special_code); $this->line->fk_parent_line=$this->fk_parent_line; $this->line->origin=$this->origin; $this->line->origin_id=$origin_id; From b4bdbda9f5058eb4394cf80134ca6405439392d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 12:36:57 +0100 Subject: [PATCH 91/99] Update mysqli.class.php --- htdocs/core/db/mysqli.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 1b040ddfa18..1e244df883f 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -256,9 +256,8 @@ class DoliDBMysqli extends DoliDB $query = trim($query); - if (empty($query)) return null; - if (! in_array($query, array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG); + if (empty($query)) return false; // Return false = error if empty request if (! $this->database_name) { From a0bc6672d8e034a8ce5ef0da736a46a7bec57f74 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 12:43:17 +0100 Subject: [PATCH 92/99] Try to avoid to make subquery when not necessary --- htdocs/adherents/class/adherent.class.php | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 15cb81f8474..47526d7cf70 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -563,18 +563,22 @@ class Adherent extends CommonObject $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest $sql.= " WHERE rowid = ".$this->id; - $sql2 = "SELECT libelle"; - $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql2.= " WHERE rowid = ".$this->typeid; - $resql2 = $this->db->query($sql2); - if($resql2) - { - while ($obj=$this->db->fetch_object($resql2)) - { - $this->type=$obj->libelle; - } - } - + // If we change the type of membership, we set also label of new type + if (! empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) + { + $sql2 = "SELECT libelle as label"; + $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql2.= " WHERE rowid = ".$this->typeid; + $resql2 = $this->db->query($sql2); + if ($resql2) + { + while ($obj=$this->db->fetch_object($resql2)) + { + $this->type=$obj->label; + } + } + } + dol_syslog(get_class($this)."::update update member", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) From 1fb86e12e5bf10177f510d75b28c45494374af25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 13:02:51 +0100 Subject: [PATCH 93/99] Merge manually some enhancement from #10507 --- htdocs/compta/compta-files.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 3917cad6133..647348269a2 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -25,15 +25,14 @@ 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.'/fourn/class/fournisseur.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/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -$langs->loadLangs(array("accountancy","bills")); +$langs->loadLangs(array("accountancy", "bills", "companies")); $date_start =GETPOST('date_start', 'alpha'); $date_startDay= GETPOST('date_startday', 'int'); @@ -49,7 +48,7 @@ $date_stop=($date_stopDay)?dol_mktime(0, 0, 0, $date_stopMonth, $date_stopDay, $ $action =GETPOST('action', 'alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('comptafileslist','globallist')); +$hookmanager->initHooks(array('comptafileslist', 'globallist')); // Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -92,7 +91,7 @@ $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, ref as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; + $sql="SELECT rowid as id, ref 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.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT; @@ -189,6 +188,7 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { //var_dump($upload_dir); if (count($files) < 1) { + $nofile['id']=$objd->id; $nofile['date']=$db->idate($objd->date); $nofile['paid']=$objd->paid; $nofile['amount']=$objd->total_ttc; @@ -202,6 +202,7 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { { foreach ($files as $key => $file) { + $file['id']=$objd->id; $file['date']=$db->idate($objd->date); $file['paid']=$objd->paid; $file['amount']=$objd->total_ttc; @@ -236,6 +237,12 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { if ($result && $action == "dl") { + if (! extension_loaded('zip')) + { + setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); + exit; + } + $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp); dol_mkdir($dirfortmpfile); From 0349f9bfaae2331f818d3c97f7a13aa15af88457 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 13:26:25 +0100 Subject: [PATCH 94/99] Update objectline_create.tpl.php --- htdocs/core/tpl/objectline_create.tpl.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d598c18a33e..73d06b3e0aa 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -260,15 +260,17 @@ else { if ($senderissupplier != 2) { $ajaxoptions=array( - 'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key - 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done - 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo) + 'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key + 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done + 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo) ); $alsoproductwithnosupplierprice=0; } else { - $ajaxoptions = array('update' => array('remise_percent' => 'discount')); + $ajaxoptions = array( + 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key + ); $alsoproductwithnosupplierprice=1; } From b9408baef3c286fc42a97c7b674d26f6a4aa2845 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 14:27:20 +0100 Subject: [PATCH 95/99] Fix if price net was not saved, we recalculate it at output --- htdocs/expensereport/card.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 3c7253f9065..ff55935ea09 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2076,8 +2076,22 @@ else print ''; print ''.dol_escape_htmltag($line->comments).''; print ''.vatrate($line->vatrate, true).''; - print ''.price($line->value_unit_ht).''; + // Unit price HT + print ''; + if (! empty($line->value_unit_ht)) + { + print price($line->value_unit_ht); + } + else + { + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $line->vatrate)); + $pricenettoshow = price2num($line->value_unit / (1 + $tmpvat / 100), 'MU'); + print $pricenettoshow; + } + print ''; + print ''.price($line->value_unit).''; + print ''.dol_escape_htmltag($line->qty).''; if ($action != 'editline') @@ -2148,12 +2162,12 @@ else // Unit price print ''; - print ''; + print ''; print ''; // Unit price with tax print ''; - print ''; + print ''; print ''; // Quantity From 31e1ad48e3fcce5434443212fa146517c1bc7003 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 14:28:09 +0100 Subject: [PATCH 96/99] css --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index ff55935ea09..e883620f3bc 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2172,7 +2172,7 @@ else // Quantity print ''; - print ''; + print ''; print ''; if ($action != 'editline') From 25fa729e4ed12d6ce69c35ccf7013dcb96d7793f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 14:32:03 +0100 Subject: [PATCH 97/99] NEW Add the now link when creating expense report --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index e883620f3bc..7d2b725c101 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2215,7 +2215,7 @@ else // Select date print ''; - print $form->selectDate($date?$date:-1, 'date'); + print $form->selectDate($date?$date:-1, 'date', 0, 0, 0, '', 1, 1); print ''; // Select project From 0798f7b7193f37e4fcbd36c32194e3c9d7d65cfe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 20:53:03 +0100 Subject: [PATCH 98/99] NEW Can upload files from the edit page of expense report --- htdocs/core/actions_linkedfiles.inc.php | 2 +- htdocs/core/class/html.formfile.class.php | 52 +++++---- htdocs/expensereport/card.php | 103 +++++++++++++++--- .../class/expensereport.class.php | 4 +- htdocs/expensereport/document.php | 2 +- htdocs/langs/en_US/trips.lang | 8 +- 6 files changed, 120 insertions(+), 51 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 73cbd572e9d..272ac1532a6 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -29,7 +29,7 @@ // Submit file/link if (GETPOST('sendit', 'alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - if (! empty($_FILES)) + if (! empty($_FILES)) { if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; else $userfiles=array($_FILES['userfile']['tmp_name']); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2577d70e549..1ea48c90091 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -77,9 +77,10 @@ class FormFile * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM) * @param string $accept Specifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*') * @param string $sectiondir If upload must be done inside a particular directory (is sectiondir defined, sectionid must not be) + * @param int $usewithoutform 0=Default, 1=Disable
and style to use in existing area * @return int <0 if KO, >0 if OK */ - public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') + public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0) { // phpcs:enable global $conf,$langs, $hookmanager; @@ -114,10 +115,13 @@ class FormFile if (empty($title)) $title=$langs->trans("AttachANewFile"); if ($title != 'none') $out.=load_fiche_titre($title, null, null); - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + if (empty($usewithoutform)) + { + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + } $out .= ''; $out .= ''; @@ -176,13 +180,7 @@ class FormFile if ($savingdocmask) { //add a global variable for disable the auto renaming on upload - if (! empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)) - { - $rename=''; - } - else { - $rename='checked'; - } + $rename=(empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)?'checked':''); $out .= ''; if (! empty($options)) $out .= ''; @@ -194,8 +192,11 @@ class FormFile $out .= "
'.$options.'
"; - $out .= '
'; - if (empty($sectionid)) $out .= '
'; + if (empty($usewithoutform)) + { + $out .= ''; + if (empty($sectionid)) $out .= '
'; + } $out .= "\n\n"; @@ -205,12 +206,16 @@ class FormFile $langs->load('link'); $title = $langs->trans("LinkANewFile"); $out .= load_fiche_titre($title, null, null); - $out .= '