From eca010937f101c908aefab9d21951bf5711424c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Feb 2021 11:56:53 +0100 Subject: [PATCH 1/4] FIX Trigger on expense report was not fired FIX Bad dates on info tabs --- htdocs/admin/delais.php | 6 +++ htdocs/core/lib/functions2.lib.php | 12 ++--- htdocs/core/menus/standard/empty.php | 8 ++-- htdocs/expensereport/card.php | 44 ++++--------------- .../class/expensereport.class.php | 7 +-- htdocs/holiday/card.php | 8 ++-- .../mysql/data/llx_c_action_trigger.sql | 2 +- .../install/mysql/migration/12.0.0-13.0.0.sql | 9 +++- htdocs/langs/en_US/agenda.lang | 1 + 9 files changed, 42 insertions(+), 55 deletions(-) diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index d605f75c511..d214a585ab2 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -33,7 +33,9 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'aZ09'); +if (empty($action)) $action = 'edit'; +// Define list of managed delays $modules = array( 'agenda' => array( array( @@ -190,6 +192,10 @@ if ($action == 'update') for ($i = 0; $i < 4; $i++) { if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); } + + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + + $action = 'edit'; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index ffc79b8f4b4..fcac069183e 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -315,7 +315,7 @@ function dol_print_object_info($object, $usetable = 0) if ($usetable) print ''; else print ': '; print dol_print_date($object->date_validation, 'dayhour', 'tzserver'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_validation, "dayhour", 'tzserver').'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_validation, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour"); if ($usetable) print ''; else print '
'; } @@ -349,7 +349,7 @@ function dol_print_object_info($object, $usetable = 0) if ($usetable) print ''; else print ': '; print dol_print_date($object->date_approve, 'dayhour', 'tzserver'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve, "dayhour", 'tzserver').'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour"); if ($usetable) print ''; else print '
'; } @@ -377,7 +377,7 @@ function dol_print_object_info($object, $usetable = 0) if ($usetable) print ''; else print ': '; print dol_print_date($object->date_approve2, 'dayhour', 'tzserver'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve2, "dayhour", 'tzserver').'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve2, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour"); if ($usetable) print ''; else print '
'; } @@ -413,7 +413,7 @@ function dol_print_object_info($object, $usetable = 0) if ($usetable) print ''; else print ': '; print dol_print_date($object->date_closing, 'dayhour', 'tzserver'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_closing, "dayhour", 'tzserver').'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_closing, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour"); if ($usetable) print ''; else print '
'; } @@ -447,7 +447,7 @@ function dol_print_object_info($object, $usetable = 0) if ($usetable) print ''; else print ': '; print dol_print_date($object->date_rappro, 'dayhour', 'tzserver'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro, "dayhour", 'tzserver').'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour"); if ($usetable) print ''; else print '
'; } @@ -460,7 +460,7 @@ function dol_print_object_info($object, $usetable = 0) if ($usetable) print ''; else print ': '; print dol_print_date($object->date_envoi, 'dayhour', 'tzserver'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_envoi, "dayhour", 'tzserver').'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_envoi, "dayhour", 'tzuserrel').'  '.$langs->trans("ClientHour"); if ($usetable) print ''; else print '
'; } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 1ab7778bb01..5ab8ff24f9f 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -198,8 +198,8 @@ class MenuManager $submenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1); $submenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1); - $submenu->add("/admin/boxes.php", $langs->trans("Boxes"), 1); - $submenu->add("/admin/delais.php", $langs->trans("Alerts"), 1); + $submenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"), 1); + $submenu->add("/admin/delais.php?mainmenu=home", $langs->trans("Alerts"), 1); $submenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"), 1); $submenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1); $submenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1); @@ -340,8 +340,8 @@ class MenuManager $this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1); $this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1); - $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"), 1); - $this->menu->add("/admin/delais.php", $langs->trans("Alerts"), 1); + $this->menu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"), 1); + $this->menu->add("/admin/delais.php?mainmenu=home", $langs->trans("Alerts"), 1); $this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"), 1); $this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1); $this->menu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 83e1173fcb4..c7efc735051 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -976,34 +976,6 @@ if (empty($reshook)) } } - if ($action == 'set_unpaid' && $id > 0 && $user->rights->expensereport->to_paid) - { - $object = new ExpenseReport($db); - $object->fetch($id); - - $result = $object->set_unpaid($user); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $object->model_pdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - } - if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) { $object = new ExpenseReport($db); @@ -1492,8 +1464,7 @@ if ($action == 'create') print ''; } else { - if ($id > 0 || $ref) - { + if ($id > 0 || $ref) { $result = $object->fetch($id, $ref); $res = $object->fetch_optionals(); @@ -1755,6 +1726,7 @@ if ($action == 'create') } print ''; + // Period print ''; print ''.$langs->trans("Period").''; print ''; @@ -1772,9 +1744,9 @@ if ($action == 'create') // Validation date print ''; print ''.$langs->trans("DATE_SAVE").''; - print ''.dol_print_date($object->date_valid, 'dayhour'); - if ($object->status == 2 && $object->hasDelay('toapprove')) print ' '.img_warning($langs->trans("Late")); - if ($object->status == 5 && $object->hasDelay('topay')) print ' '.img_warning($langs->trans("Late")); + print ''.dol_print_date($object->date_valid, 'dayhour', 'tzuser'); + if ($object->status == 2 && $object->hasDelay('toapprove')) print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToApprove")); + if ($object->status == 5 && $object->hasDelay('topay')) print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToPay")); print ''; print ''; @@ -1815,7 +1787,7 @@ if ($action == 'create') print ''; print ''; print ''.$langs->trans("DATE_CANCEL").''; - print ''.dol_print_date($object->date_cancel, 'dayhour').''; + print ''.dol_print_date($object->date_cancel, 'dayhour', 'tzuser').''; print ''; } else { print ''; @@ -1831,7 +1803,7 @@ if ($action == 'create') print ''; print ''.$langs->trans("DateApprove").''; - print ''.dol_print_date($object->date_approve, 'dayhour').''; + print ''.dol_print_date($object->date_approve, 'dayhour', 'tzuser').''; print ''; } @@ -1847,7 +1819,7 @@ if ($action == 'create') print ''; print ''.$langs->trans("DATE_REFUS").''; - print ''.dol_print_date($object->date_refuse, 'dayhour'); + print ''.dol_print_date($object->date_refuse, 'dayhour', 'tzuser'); if ($object->detail_refuse) print ' - '.$object->detail_refuse; print ''; print ''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index ad55ec4b537..31c48d790f4 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2454,10 +2454,11 @@ class ExpenseReport extends CommonObject if ($option == 'topay' && $this->status != 5) return false; $now = dol_now(); - if ($option == 'toapprove') - { + if ($option == 'toapprove') { return ($this->datevalid ? $this->datevalid : $this->date_valid) < ($now - $conf->expensereport->approve->warning_delay); - } else return ($this->datevalid ? $this->datevalid : $this->date_valid) < ($now - $conf->expensereport->payment->warning_delay); + } else { + return ($this->datevalid ? $this->datevalid : $this->date_valid) < ($now - $conf->expensereport->payment->warning_delay); + } } /** diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 09165ee89d1..bbd5a1ac9d4 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1369,24 +1369,24 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print ''; print ''.$langs->trans('DateCreation').''; - print ''.dol_print_date($object->date_create, 'dayhour').''; + print ''.dol_print_date($object->date_create, 'dayhour', 'tzuser').''; print ''; if ($object->statut == Holiday::STATUS_APPROVED || $object->statut == Holiday::STATUS_CANCELED) { print ''; print ''.$langs->trans('DateValidCP').''; - print ''.dol_print_date($object->date_valid, 'dayhour').''; // warning: date_valid is approval date on holiday module + print ''.dol_print_date($object->date_valid, 'dayhour', 'tzuser').''; // warning: date_valid is approval date on holiday module print ''; } if ($object->statut == Holiday::STATUS_CANCELED) { print ''; print ''.$langs->trans('DateCancelCP').''; - print ''.dol_print_date($object->date_cancel, 'dayhour').''; + print ''.dol_print_date($object->date_cancel, 'dayhour', 'tzuser').''; print ''; } if ($object->statut == Holiday::STATUS_REFUSED) { print ''; print ''.$langs->trans('DateRefusCP').''; - print ''.dol_print_date($object->date_refuse, 'dayhour').''; + print ''.dol_print_date($object->date_refuse, 'dayhour', 'tzuser').''; print ''; } print ''; diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 7390c3234a5..05e52c85e4b 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -102,7 +102,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAID','Expense report billed','Executed when an expense report is set as billed','expensereport',204); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',205); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',205); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',211); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',212); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_VALIDATE','Project validation','Executed when a project is validated','project',141); diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index cc484477ab6..f75ef8adee6 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -565,5 +565,12 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64); ALTER TABLE llx_projet ADD COLUMN fk_opp_status_end integer DEFAULT NULL; - +UPDATE llx_c_action_trigger SET elementtype = 'expensereport' where elementtype = 'expense_report' AND code like 'EXPENSE_%'; UPDATE llx_c_action_trigger SET code = 'EXPENSE_REPORT_PAID' where code = 'EXPENSE_REPORT_PAYED'; +UPDATE llx_c_action_trigger SET code = 'EXPENSE_REPORT_DELETE' where code = 'EXPENSE_DELETE'; +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAID','Expense report billed','Executed when an expense report is set as billed','expensereport',204); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',205); + diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 8971e80a8f8..33e0c01aad6 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -119,6 +119,7 @@ MRP_MO_UNVALIDATEInDolibarr=MO set to draft status MRP_MO_PRODUCEDInDolibarr=MO produced MRP_MO_DELETEInDolibarr=MO deleted MRP_MO_CANCELInDolibarr=MO canceled +PAIDInDolibarr=%s paid ##### End agenda events ##### AgendaModelModule=Document templates for event DateActionStart=Start date From 284042af7aaaca0e3e452deafeb8a3f9bc01a006 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Feb 2021 12:05:28 +0100 Subject: [PATCH 2/4] FIX User creation of expense report not visible --- htdocs/expensereport/class/expensereport.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 31c48d790f4..7ac1924fec8 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -256,6 +256,7 @@ class ExpenseReport extends CommonObject $sql .= ",date_debut"; $sql .= ",date_fin"; $sql .= ",date_create"; + $sql .= ",fk_user_creat"; $sql .= ",fk_user_author"; $sql .= ",fk_user_validator"; $sql .= ",fk_user_approve"; @@ -274,6 +275,7 @@ class ExpenseReport extends CommonObject $sql .= ", '".$this->db->idate($this->date_debut)."'"; $sql .= ", '".$this->db->idate($this->date_fin)."'"; $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".$user->id; $sql .= ", ".$fuserid; $sql .= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator : "null"); $sql .= ", ".($this->fk_user_approve > 0 ? $this->fk_user_approve : "null"); @@ -419,6 +421,7 @@ class ExpenseReport extends CommonObject $this->fk_statut = 0; // deprecated // Clear fields + $this->fk_user_creat = $user->id; $this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. $this->fk_user_valid = ''; $this->date_create = ''; @@ -548,7 +551,7 @@ class ExpenseReport extends CommonObject $sql .= " d.date_refuse, d.date_cancel,"; // ACTIONS $sql .= " d.total_ht, d.total_ttc, d.total_tva,"; // TOTAUX (int) $sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve,"; // DATES (datetime) - $sql .= " d.fk_user_author, d.fk_user_modif, d.fk_user_validator,"; + $sql .= " d.fk_user_creat, d.fk_user_author, d.fk_user_modif, d.fk_user_validator,"; $sql .= " d.fk_user_valid, d.fk_user_approve,"; $sql .= " d.fk_statut as status, d.fk_c_paiement, d.paid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d"; @@ -585,6 +588,7 @@ class ExpenseReport extends CommonObject $this->date_refuse = $this->db->jdate($obj->date_refuse); $this->date_cancel = $this->db->jdate($obj->date_cancel); + $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_author = $obj->fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. $this->fk_user_modif = $obj->fk_user_modif; $this->fk_user_validator = $obj->fk_user_validator; @@ -733,7 +737,7 @@ class ExpenseReport extends CommonObject $sql .= " f.tms as date_modification,"; $sql .= " f.date_valid as datev,"; $sql .= " f.date_approve as datea,"; - //$sql.= " f.fk_user_author as fk_user_creation,"; // This is not user of creation but user the expense is for. + $sql .= " f.fk_user_creat as fk_user_creation,"; $sql .= " f.fk_user_modif as fk_user_modification,"; $sql .= " f.fk_user_valid,"; $sql .= " f.fk_user_approve"; From 524b28d8c380baa099f5daa16600bedaedf889d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Feb 2021 12:15:31 +0100 Subject: [PATCH 3/4] Fix missing tab info on holiday --- htdocs/core/lib/holiday.lib.php | 5 ++ htdocs/holiday/class/holiday.class.php | 75 +++++++++++++++++ htdocs/holiday/info.php | 106 +++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 htdocs/holiday/info.php diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index f5297f6fd89..7b9c5d46da2 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -51,6 +51,11 @@ function holiday_prepare_head($object) $head[$h][2] = 'documents'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/holiday/info.php?id='.$object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 2030ab1d636..f61c0a66ca8 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2073,6 +2073,81 @@ class Holiday extends CommonObject } + /** + * Load information on object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + global $conf; + + $sql = "SELECT f.rowid,"; + $sql .= " f.date_create as datec,"; + $sql .= " f.tms as date_modification,"; + $sql .= " f.date_valid as datev,"; + //$sql .= " f.date_approve as datea,"; + $sql .= " f.date_refuse as dater,"; + $sql .= " f.fk_user_create as fk_user_creation,"; + $sql .= " f.fk_user_modif as fk_user_modification,"; + $sql .= " f.fk_user_valid,"; + $sql .= " f.fk_validator as fk_user_approve,"; + $sql .= " f.fk_user_refuse as fk_user_refuse"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as f"; + $sql .= " WHERE f.rowid = ".$id; + $sql .= " AND f.entity = ".$conf->entity; + + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->date_modification); + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_approbation = $this->db->jdate($obj->datea); + + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + + if ($obj->fk_user_creation) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_creation); + $this->user_creation = $cuser; + } + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + if ($obj->fk_user_modification) + { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modification); + $this->user_modification = $muser; + } + if ($obj->fk_user_approve) + { + $auser = new User($this->db); + $auser->fetch($obj->fk_user_approve); + $this->user_approve = $auser; + } + } + $this->db->free($resql); + } else { + dol_print_error($this->db); + } + } + + /** * Initialise an instance with random values. * Used to build previews or test instances. diff --git a/htdocs/holiday/info.php b/htdocs/holiday/info.php new file mode 100644 index 00000000000..2209143001c --- /dev/null +++ b/htdocs/holiday/info.php @@ -0,0 +1,106 @@ + + * Copyright (C) 2004-2015 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/holiday/info.php + * \ingroup holiday + * \brief Page to show a leave information + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; + +// Load translation files required by the page +$langs->load("holiday"); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + +$childids = $user->getAllChildIds(1); + +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'holiday', $id, 'holiday'); + +$object = new Holiday($db); +if (!$object->fetch($id, $ref) > 0) +{ + dol_print_error($db); +} + +if ($object->id > 0) +{ + // Check current user can read this expense report + $canread = 0; + if (!empty($user->rights->holiday->readall)) $canread = 1; + if (!empty($user->rights->holiday->lire) && in_array($object->fk_user_author, $childids)) $canread = 1; + if (!$canread) + { + accessforbidden(); + } +} + + +/* + * View + */ + +$form = new Form($db); + +$title = $langs->trans("Holiday")." - ".$langs->trans("Info"); +$helpurl = ""; +llxHeader("", $title, $helpurl); + +if ($id > 0 || !empty($ref)) +{ + $object = new Holiday($db); + $object->fetch($id, $ref); + $object->info($object->id); + + $head = holiday_prepare_head($object); + + print dol_get_fiche_head($head, 'info', $langs->trans("Holiday"), -1, 'holiday'); + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + + print '
'; + + print '
'; + dol_print_object_info($object); + print '
'; + + print '
'; + + print dol_get_fiche_end(); +} + +// End of page +llxFooter(); +$db->close(); From b58b3a493234f65cf6fa3be589bd9bd4c707fb7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Feb 2021 13:03:05 +0100 Subject: [PATCH 4/4] FIX link to create event when task is in a project with a thirdparty --- htdocs/projet/tasks/task.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index da15a73f66f..1ba2373f35d 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -650,7 +650,8 @@ if ($id > 0 || !empty($ref)) // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject); + $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid; + $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject); print ''; }