diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 7b4d2f6bba9..7ec39b7eda8 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -195,6 +195,7 @@ if ($conf->use_javascript_ajax) { $SommeA = 0; $SommeB = 0; + $SommeC = 0; $SommeD = 0; $total = 0; @@ -218,7 +219,7 @@ if ($conf->use_javascript_ajax) { $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); @@ -492,6 +493,8 @@ print ''; print "\n"; print ""; +print '
'; + print $resultboxes['boxlistb']; print ''."\n"; diff --git a/htdocs/conf/.gitignore b/htdocs/conf/.gitignore index ed21fdfaa4c..8d06ea77328 100644 --- a/htdocs/conf/.gitignore +++ b/htdocs/conf/.gitignore @@ -5,3 +5,4 @@ /conf.php.pgsql /conf.php.sqlite /conf.php.utf8 +/conf.php.nov* diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index ca77fec51e4..e4418020bfc 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -41,6 +41,8 @@ class box_graph_invoices_permonth extends ModeleBoxes public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + /** * Constructor diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 21931b1a071..5ecc26c3f90 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -41,6 +41,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + /** * Constructor diff --git a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php index 9595d264ee4..31b6bb20a8d 100644 --- a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php +++ b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box */ -class box_nb_ticket_last_x_days extends ModeleBoxes +class box_graph_nb_ticket_last_x_days extends ModeleBoxes { public $boxcode = "box_nb_ticket_last_x_days"; @@ -36,14 +36,12 @@ class box_nb_ticket_last_x_days extends ModeleBoxes public $boxlabel; public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $param; public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + /** * Constructor * @param DoliDB $db Database handler diff --git a/htdocs/core/boxes/box_graph_nb_tickets_type.php b/htdocs/core/boxes/box_graph_nb_tickets_type.php index 10eebc05b06..eea0f0ccf77 100644 --- a/htdocs/core/boxes/box_graph_nb_tickets_type.php +++ b/htdocs/core/boxes/box_graph_nb_tickets_type.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box */ -class box_nb_tickets_type extends ModeleBoxes +class box_graph_nb_tickets_type extends ModeleBoxes { public $boxcode = "box_nb_tickets_type"; @@ -36,14 +36,13 @@ class box_nb_tickets_type extends ModeleBoxes public $boxlabel; public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $param; public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + + /** * Constructor * @param DoliDB $db Database handler diff --git a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php index 32eb82984e7..bd835d6cc07 100644 --- a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php +++ b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box */ -class box_new_vs_close_ticket extends ModeleBoxes +class box_graph_new_vs_close_ticket extends ModeleBoxes { public $boxcode = "box_nb_tickets_type"; @@ -36,14 +36,13 @@ class box_new_vs_close_ticket extends ModeleBoxes public $boxlabel; public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $param; public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + + /** * Constructor * @param DoliDB $db Database handler diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index ec11d07a28f..48f0bd67ec3 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -41,6 +41,8 @@ class box_graph_orders_permonth extends ModeleBoxes public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + /** * Constructor diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index a6dfead80f0..a394834cd97 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -41,6 +41,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + /** * Constructor diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 5c3e55fcc2f..4a88617de4e 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -44,6 +44,8 @@ class box_graph_product_distribution extends ModeleBoxes public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + /** * Constructor diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index f8028e3bdb8..8a95761ea08 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -41,6 +41,8 @@ class box_graph_propales_permonth extends ModeleBoxes public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + /** * Constructor diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index 52c3e938798..252769abd0e 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box */ -class box_ticket_by_severity extends ModeleBoxes +class box_graph_ticket_by_severity extends ModeleBoxes { public $boxcode = "box_ticket_by_severity"; @@ -45,6 +45,9 @@ class box_ticket_by_severity extends ModeleBoxes public $info_box_head = array(); public $info_box_contents = array(); + public $widgettype = 'graph'; + + /** * Constructor * @param DoliDB $db Database handler diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 379a65b7a5d..b7b9d979174 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -109,6 +109,12 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box */ public $note; + /** + * @var string Widget type ('graph' means the widget is a graph widget) + */ + public $widgettype = ''; + + /** * Constructor * diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 127bfd2fd50..ed986cadbb3 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1150,7 +1150,7 @@ class FormOther if (boxorder==\'A:A-B:B\' && closing == 1) // There is no more boxes on screen, and we are after a delete of a box so we must hide title { jQuery.ajax({ - url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=0&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.', + url: \''.DOL_URL_ROOT.'/core/ajax/box.php?closing=1&boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.', async: false }); // We force reload to be sure to get all boxes into list diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index a4299e925df..c8c2c5cdc2b 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -620,8 +620,8 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } } } elseif (in_array($feature, $checksoc)) { // We check feature = checksoc - if ($user->socid > 0) { - // If external user: Check permission for external users + // If external user: Check permission for external users + if ($user->socid > 0 && empty($conf->global->MAIN_EXTERNAL_USERS_CAN_SEE_SUBSIDIARY_COMPANIES)) { if ($user->socid <> $objectid) { return false; } diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index b0527ad30b5..77d0cc0c81f 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -66,7 +66,7 @@ class modEventOrganization extends DolibarrModules // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( // Set this to 1 if module has its own trigger directory (core/triggers) - 'triggers' => 0, + 'triggers' => 1, // Set this to 1 if module has its own login method file (core/login) 'login' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 781948d0f52..3da2523ad40 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -64,7 +64,7 @@ class modProductBatch extends DolibarrModules // Data directories to create when module is enabled. $this->dirs = array(); - // Config pages. Put here list of php page, stored into productdluo/admin directory, to use to setup module. + // Config pages. Put here list of php page, stored into /product/admin/ directory, to setup the module. $this->config_page_url = array("product_lot_extrafields.php@product"); // Dependencies diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 8f7ed11ba16..fc5cbd1027e 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1557,8 +1557,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'border-left' => true, // add left line separator ); - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) - { + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE)) { $this->cols['subprice']['status'] = true; } @@ -1612,8 +1611,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'border-left' => true, // add left line separator ); - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) - { + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN)) { $this->cols['totalexcltax']['status'] = true; } diff --git a/htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php b/htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php new file mode 100644 index 00000000000..386a723bb5e --- /dev/null +++ b/htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php @@ -0,0 +1,126 @@ + + * Copyright (C) 2021 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php + * \ingroup eventorganization + * \brief Trigger file for Event Organization module + */ + +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + + +/** + * Class of triggered functions for agenda module + */ +class InterfaceEventOrganization extends DolibarrTriggers +{ + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "eventorganization"; + $this->description = "Triggers of this module to manage event organization triggers action"; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'action'; + } + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) + * + * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: + * $object->actiontypecode (translation action code: AC_OTH, ...) + * $object->actionmsg (note, long text) + * $object->actionmsg2 (label, short text) + * $object->sendtoid (id of contact or array of ids of contacts) + * $object->socid (id of thirdparty) + * $object->fk_project + * $object->fk_element (ID of object to link action event to) + * $object->elementtype (->element of object to link action to) + * $object->module (if defined, elementtype in llx_actioncomm will be elementtype@module) + * + * @param string $action Event action code ('CONTRACT_MODIFY', 'RECRUITMENTCANDIDATURE_MODIFIY', ...) + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + if (empty($conf->eventorganization->enabled)) { + return 0; // Module not active, we do nothing + } + + $error=0; + + // Actions + if ($action == 'PROJECT_VALIDATE') { + if (!empty($conf->global->EVENTORGANIZATION_TASK_LABEL) && !empty($object->usage_organize_event)) { + $taskToDo = explode("\n", $conf->global->EVENTORGANIZATION_TASK_LABEL); + if (is_array($taskToDo) && count($taskToDo)>0) { + // Load translation files required by the page + $langs->loadLangs(array("eventorganization")); + + $this->db->begin(); + foreach ($taskToDo as $taskLabel) { + $task = new Task($this->db); + $task->label = $taskLabel; + $task->fk_project = $object->id; + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) { + require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php'; + $modTask = new $obj; + $defaultref = $modTask->getNextValue($object->thirdparty, null); + } + if (is_numeric($defaultref) && $defaultref <= 0) { + $defaultref = ''; + } + $task->ref = $defaultref; + $task->date_start = $object->date_start; + $task->date_end = $object->date_end; + $result = $task->create($user); + if ($result < 0) { + $this->errors=array_merge($this->errors, $task->errors); + $error++; + } + } + + if (empty($error)) { + $this->db->commit(); + return 1; + } else { + dol_syslog("InterfaceEventOrganization.class.php: ".implode(',', $this->errors), LOG_ERR); + $this->db->rollback(); + return -1; + } + } + } + } + return 0; + } +} diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index d1507d52418..5c162c4bf4f 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -510,7 +510,7 @@ if (empty($reshook)) { } } elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer) { // Classify Billed - $result = $object->setStatut(2); + $result = $object->setStatut(Fichinter::STATUS_BILLED); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; @@ -519,7 +519,7 @@ if (empty($reshook)) { } } elseif ($action == 'classifyunbilled' && $user->rights->ficheinter->creer) { // Classify unbilled - $result = $object->setStatut(1); + $result = $object->setStatut(Fichinter::STATUS_VALIDATED); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; @@ -528,7 +528,7 @@ if (empty($reshook)) { } } elseif ($action == 'classifydone' && $user->rights->ficheinter->creer) { // Classify Done - $result = $object->setStatut(3); + $result = $object->setStatut(Fichinter::STATUS_CLOSED); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; diff --git a/htdocs/langs/bs_BA/admin.lang b/htdocs/langs/bs_BA/admin.lang index 8edb636b439..268bcdc7337 100644 --- a/htdocs/langs/bs_BA/admin.lang +++ b/htdocs/langs/bs_BA/admin.lang @@ -1367,7 +1367,7 @@ BillsNumberingModule=Invoices and credit notes numbering model BillsPDFModules=Invoice documents models BillsPDFModulesAccordindToInvoiceType=Invoice documents models according to invoice type PaymentsPDFModules=Payment documents models -ForceInvoiceDate=Force invoice date to validation date +ForceInvoiceDate=Force invoice date to validation date (forcing is possible only the first time an invoice is validated) SuggestedPaymentModesIfNotDefinedInInvoice=Suggested payments mode on invoice by default if not defined on the invoice SuggestPaymentByRIBOnAccount=Suggest payment by withdrawal on account SuggestPaymentByChequeToAddress=Suggest payment by check to diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 4ddf0d6093f..5ec33145da1 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -14,7 +14,7 @@ SuppliersCategoriesArea=Vendors tags/categories area CustomersCategoriesArea=Customers tags/categories area MembersCategoriesArea=Members tags/categories area ContactsCategoriesArea=Contacts tags/categories area -AccountsCategoriesArea=Accounts tags/categories area +AccountsCategoriesArea=Bank accounts tags/categories area ProjectsCategoriesArea=Projects tags/categories area UsersCategoriesArea=Users tags/categories area SubCats=Sub-categories diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index e356792ed42..23809eb6a33 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -77,6 +77,12 @@ class mymodulewidget1 extends ModeleBoxes */ public $info_box_contents = array(); + /** + * @var string Widget type ('graph' means the widget is a graph widget) + */ + public $widgettype = 'graph'; + + /** * Constructor * diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index d911a53ef5e..6fd903c0038 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -248,7 +248,8 @@ class Mo extends CommonObject $this->db->begin(); - if ($this->fk_product > 0) { + // Check that product is not a kit/virtual product + if (empty($conf->global->ALLOW_USE_KITS_INTO_BOM_AND_MO) and $this->fk_product > 0) { include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $tmpproduct = new Product($this->db); $tmpproduct->fetch($this->fk_product); @@ -260,7 +261,6 @@ class Mo extends CommonObject } } - // Check that product is not a kit/virtual product if (!$error) { $idcreated = $this->createCommon($user, $notrigger); if ($idcreated <= 0) { diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 1a3967f2de7..1ab642dab83 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1363,12 +1363,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; - if ($type == 0) { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); - } else { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); - } - print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); + if ($type == 0) { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); + } else { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1); print ''; // Accountancy_code_buy_intra diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 334ceffb822..72d7d4838c0 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -61,6 +61,7 @@ $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", $datesp = dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int')); $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int')); $label = GETPOST('label'); +$fk_user = GETPOST('userid', 'int'); // Security check $socid = GETPOST("socid", "int"); @@ -107,7 +108,17 @@ if ($action == 'confirm_paid' && $user->rights->salaries->write && $confirm == ' $result = $object->set_paid($user); } -// Reopen +if ($action == 'setfk_user' && $user->rights->salaries->write) { + $result = $object->fetch($id); + if ($result > 0) { + $object->fk_user = $fk_user; + $object->update($user); + } else { + dol_print_error($db); + exit; + } +} + if ($action == 'reopen' && $user->rights->salaries->write) { $result = $object->fetch($id); if ($object->paye) { @@ -421,7 +432,7 @@ if ($action == 'create') { print ''; // Employee - print ''; // Project @@ -461,7 +472,7 @@ if ($action == 'create') { } // Comments - print ''; + print ''; print ''; print ''; print ''; @@ -593,10 +604,37 @@ if ($id) { $morehtmlref .= ''; } - // Employee - $userstatic = new User($db); - $userstatic->fetch($object->fk_user); - $morehtmlref .= '
' .$langs->trans('Employee').' : '.$userstatic->getNomUrl(1); + //Employee + if ($action != 'editfk_user') { + if ($object->getSommePaiement() > 0 && !empty($object->fk_user)) { + $userstatic = new User($db); + $result = $userstatic->fetch($object->fk_user); + if ($result > 0) { + $morehtmlref .= '
' .$langs->trans('Employee').' : '.$userstatic->getNomUrl(1); + } + } else { + $morehtmlref .= '
' . $form->editfieldkey("Employee", 'fk_user', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1); + + if (!empty($object->fk_user)) { + $userstatic = new User($db); + $result = $userstatic->fetch($object->fk_user); + if ($result > 0) { + $morehtmlref .= $userstatic->getNomUrl(1); + } else { + dol_print_error($db); + exit(); + } + } + } + } else { + $morehtmlref .= '
'.$langs->trans('Employee').' : '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $form->select_dolusers($object->fk_user, 'userid', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } // Project if (!empty($conf->projet->enabled)) { @@ -674,7 +712,7 @@ if ($id) { print '';*/ if ($action == 'edit') { - print ''; + print ''; } else { print ''; } diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php index 7d7f9a7b5f2..123dc044a4a 100644 --- a/htdocs/salaries/class/salariesstats.class.php +++ b/htdocs/salaries/class/salariesstats.class.php @@ -62,8 +62,8 @@ class SalariesStats extends Stats $this->from = MAIN_DB_PREFIX.$object->table_element; $this->field = 'amount'; - $this->where .= " entity = ".$conf->entity; - if ($this->socid) { + $this->where = " entity = ".$conf->entity; + if ($this->socid > 0) { $this->where .= " AND fk_soc = ".$this->socid; } if (is_array($this->userid) && count($this->userid) > 0) { @@ -83,8 +83,8 @@ class SalariesStats extends Stats { $sql = "SELECT YEAR(datep) as dm, count(*)"; $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm DESC"; - //$sql .= " WHERE ".$this->where; return $this->_getNbByYear($sql); } @@ -102,12 +102,12 @@ class SalariesStats extends Stats $sql = "SELECT MONTH(datep) as dm, count(*)"; $sql .= " FROM ".$this->from; $sql .= " WHERE YEAR(datep) = ".$year; - //$sql .= " AND ".$this->where; + $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); - //var_dump($res);print '
'; + return $res; } @@ -124,12 +124,11 @@ class SalariesStats extends Stats $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; $sql .= " FROM ".$this->from; $sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'"; - //$sql .= " AND ".$this->where; + $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getAmountByMonth($year, $sql, $format); - //var_dump($res);print '
'; return $res; } @@ -145,7 +144,7 @@ class SalariesStats extends Stats $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; $sql .= " FROM ".$this->from; $sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'"; - //$sql .= " AND ".$this->where; + $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -161,7 +160,7 @@ class SalariesStats extends Stats { $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql .= " FROM ".$this->from; - //$sql .= " WHERE ".$this->where; + $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; $sql .= $this->db->order('year', 'DESC'); diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index ac746a215e3..1fe914d38c2 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -33,10 +33,12 @@ $langs->loadLangs(array("salaries", "companies", "bills")); $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$userid = GETPOST('userid', 'int'); if ($userid < 0) { +$userid = GETPOST('userid', 'int'); +if ($userid < 0) { $userid = 0; } -$socid = GETPOST('socid', 'int'); if ($socid < 0) { +$socid = GETPOST('socid', 'int'); +if ($socid < 0) { $socid = 0; } $id = GETPOST('id', 'int'); @@ -201,8 +203,8 @@ print ''; print '
'; + print '
'; print $form->editfieldkey('Employee', 'fk_user', '', $object, 0, 'string', '', 1).''; $noactive = 0; // We keep active and unactive users print img_picto('', 'user', 'class="paddingrighonly"').$form->select_dolusers(GETPOST('fk_user', 'int'), 'fk_user', 1, '', 0, '', '', 0, 0, 0, 'AND employee=1', 0, '', 'maxwidth300', $noactive); @@ -448,7 +459,7 @@ if ($action == 'create') { // Amount print '
'; print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).''; - print ''; + print ''; print '
'.$langs->trans("Comments").'
' . $langs->trans("Amount") . '
' . $langs->trans("Amount") . '
' . $langs->trans("Amount") . '' . price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency) . '
'; print ''; // User -print ''; // Year print '
'.$langs->trans("Filter").'
'.$langs->trans("User").''; -print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); +print '
'.$langs->trans("Employee").''; +print $form->select_dolusers(($userid ? $userid : -1), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
'.$langs->trans("Year").''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e0131a420fb..d69a602c900 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -80,7 +80,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); -if ($user->socid) { +if ($user->socid && empty($conf->global->MAIN_EXTERNAL_USERS_CAN_SEE_SUBSIDIARY_COMPANIES)) { $socid = $user->socid; } if (empty($socid) && $action == 'view') { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 508a871de68..03cd9366aba 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2060,6 +2060,19 @@ if ($action == 'exportsite') { // Regenerate site if ($action == 'regeneratesite') { + // Check symlink to medias and restore it if ko. Recreate also dir of website if not found. + $pathtomedias = DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite = $pathofwebsite.'/medias'; + if (!is_link(dol_osencode($pathtomediasinwebsite))) { + dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + $result = symlink($pathtomedias, $pathtomediasinwebsite); + if (!$result) { + setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors'); + $action = 'preview'; + } + } + $result = $object->rebuildWebSiteFiles(); if ($result > 0) { setEventMessages($langs->trans("PagesRegenerated", $result), null, 'mesgs'); @@ -2077,7 +2090,7 @@ if ($action == 'importsiteconfirm') { $action = 'importsite'; } else { if (!empty($_FILES) || GETPOSTISSET('templateuserfile')) { - // Check symlink to medias and restore it if ko + // Check symlink to medias and restore it if ko. Recreate also dir of website if not found. $pathtomedias = DOL_DATA_ROOT.'/medias'; $pathtomediasinwebsite = $pathofwebsite.'/medias'; if (!is_link(dol_osencode($pathtomediasinwebsite))) {