From 19b1dd5a11dbbf22b84e979584f535e31dc3e3b0 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 20 Oct 2023 14:12:42 +0200 Subject: [PATCH 1/3] Fix misspelled @throw -> @throws (#26297) Identified using phan, see #26262 --- .../dolistore/class/PSWebServiceLibrary.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index de6210ba531..89df1ec2aa4 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -225,7 +225,7 @@ class PrestaShopWebservice * @param string $response String from a CURL response * @return SimpleXMLElement|boolean status_code, response * - * @throw PrestaShopWebserviceException + * @throws PrestaShopWebserviceException */ protected function parseXML($response) { @@ -257,7 +257,7 @@ class PrestaShopWebservice * @param array $options Options * @return SimpleXMLElement|boolean status_code, response * - * @throw PrestaShopWebserviceException + * @throws PrestaShopWebserviceException */ public function add($options) { @@ -310,7 +310,7 @@ class PrestaShopWebservice * @param array $options Array representing resource to get. * @return SimpleXMLElement|boolean status_code, response * - * @throw PrestaShopWebserviceException + * @throws PrestaShopWebserviceException */ public function get($options) { @@ -351,7 +351,7 @@ class PrestaShopWebservice * @param array $options Array representing resource for head request. * @return SimpleXMLElement status_code, response * - * @throw PrestaShopWebserviceException + * @throws PrestaShopWebserviceException */ public function head($options) { @@ -393,7 +393,7 @@ class PrestaShopWebservice * @param array $options Array representing resource to edit. * @return SimpleXMLElement|boolean status_code, response * - * @throw PrestaShopWebserviceException + * @throws PrestaShopWebserviceException */ public function edit($options) { From 9361b1269b230ca8ebe743d1b4b6c845dc500901 Mon Sep 17 00:00:00 2001 From: V-Py <59333024+V-Py@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:28:52 +0200 Subject: [PATCH 2/3] FIX #25143 Using default_values for extrafields by replacing GETPOSTISSET by GETPOST (#25233) * FIX #25143 Using default_values for extrafields * Update extrafields.class.php correct the indentation error --- htdocs/core/class/extrafields.class.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b0e024f699b..cb1b76c2144 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2252,16 +2252,17 @@ class ExtraFields if (in_array($key_type, array('date'))) { $dateparamname_start = $keysuffix . 'options_' . $key . $keyprefix . '_start'; $dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end'; - if (GETPOSTISSET($dateparamname_start . 'year') || GETPOSTISSET($dateparamname_end . 'year')) { + + if (GETPOST($dateparamname_start . 'year') && GETPOST($dateparamname_end . 'year')) { $value_key = array(); // values provided as a component year, month, day, etc. - if (GETPOSTISSET($dateparamname_start . 'year')) { + if (GETPOST($dateparamname_start . 'year')) { $value_key['start'] = dol_mktime(0, 0, 0, GETPOST($dateparamname_start . 'month', 'int'), GETPOST($dateparamname_start . 'day', 'int'), GETPOST($dateparamname_start . 'year', 'int')); } - if (GETPOSTISSET($dateparamname_start . 'year')) { + if (GETPOST($dateparamname_start . 'year')) { $value_key['end'] = dol_mktime(23, 59, 59, GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int')); } - } elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) { + } elseif (GETPOST($keysuffix."options_".$key.$keyprefix."year")) { // Clean parameters $value_key = dol_mktime(12, 0, 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); } else { @@ -2270,7 +2271,7 @@ class ExtraFields } elseif (in_array($key_type, array('datetime', 'datetimegmt'))) { $dateparamname_start = $keysuffix . 'options_' . $key . $keyprefix . '_start'; $dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end'; - if (GETPOSTISSET($dateparamname_start . 'year') && GETPOSTISSET($dateparamname_end . 'year')) { + if (GETPOST($dateparamname_start . 'year') && GETPOST($dateparamname_end . 'year')) { // values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc. $dateparamname_end_hour = GETPOST($dateparamname_end . 'hour', 'int') !='-1' ? GETPOST($dateparamname_end . 'hour', 'int') : '23'; $dateparamname_end_min = GETPOST($dateparamname_end . 'min', 'int') !='-1' ? GETPOST($dateparamname_end . 'min', 'int') : '59'; @@ -2286,7 +2287,7 @@ class ExtraFields 'end' => dol_mktime($dateparamname_end_hour, $dateparamname_end_min, $dateparamname_end_sec, GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int'), 'tzuserrel') ); } - } elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) { + } elseif (GETPOST($keysuffix."options_".$key.$keyprefix."year")) { // Clean parameters if ($key_type == 'datetimegmt') { $value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."sec", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'), 'gmt'); @@ -2307,7 +2308,7 @@ class ExtraFields $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); } } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { + if (!GETPOST($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. } $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); @@ -2315,7 +2316,7 @@ class ExtraFields $value_arr = (array) $value_arr; $value_key = implode(',', $value_arr); } elseif (in_array($key_type, array('price', 'double', 'int'))) { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { + if (!GETPOST($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. } $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); @@ -2325,19 +2326,19 @@ class ExtraFields $value_key = $value_arr; } } elseif (in_array($key_type, array('boolean'))) { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { + if (!GETPOST($keysuffix."options_".$key.$keyprefix)) { $value_key = ''; } else { $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = $value_arr; } } elseif (in_array($key_type, array('html'))) { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { + if (!GETPOST($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. } $value_key = dol_htmlcleanlastbr(GETPOST($keysuffix."options_".$key.$keyprefix, 'restricthtml')); } else { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { + if (!GETPOST($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. } $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); From 60fa585a7ff11f6151bfb7588a1837522da888cd Mon Sep 17 00:00:00 2001 From: mc2contributor Date: Fri, 20 Oct 2023 06:33:39 -0600 Subject: [PATCH 3/3] CLOSE #23331 Add support for parent projects (#24856) --- htdocs/projet/card.php | 62 +++++++++++++++++++++++++++ htdocs/projet/class/project.class.php | 39 ++++++++++++++++- 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 7852e985c04..c4f5559fa76 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -68,6 +68,7 @@ $date_end = dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('proj $date_start_event = dol_mktime(GETPOST('date_start_eventhour', 'int'), GETPOST('date_start_eventmin', 'int'), GETPOST('date_start_eventsec', 'int'), GETPOST('date_start_eventmonth', 'int'), GETPOST('date_start_eventday', 'int'), GETPOST('date_start_eventyear', 'int')); $date_end_event = dol_mktime(GETPOST('date_end_eventhour', 'int'), GETPOST('date_end_eventmin', 'int'), GETPOST('date_end_eventsec', 'int'), GETPOST('date_end_eventmonth', 'int'), GETPOST('date_end_eventday', 'int'), GETPOST('date_end_eventyear', 'int')); $location = GETPOST('location', 'alphanohtml'); +$fk_project = GETPOST('fk_project', 'int'); $mine = GETPOST('mode') == 'mine' ? 1 : 0; @@ -205,6 +206,7 @@ if (empty($reshook)) { $db->begin(); $object->ref = GETPOST('ref', 'alphanohtml'); + $object->fk_project = GETPOST('fk_project', 'int'); $object->title = GETPOST('title', 'alphanohtml'); $object->socid = GETPOST('socid', 'int'); $object->description = GETPOST('description', 'restricthtml'); // Do not use 'alpha' here, we want field as it is @@ -304,6 +306,7 @@ if (empty($reshook)) { $old_start_date = $object->date_start; $object->ref = GETPOST('ref', 'alpha'); + $object->fk_project = GETPOST('fk_project', 'int'); $object->title = GETPOST('title', 'alphanohtml'); // Do not use 'alpha' here, we want field as it is $object->statut = GETPOST('status', 'int'); $object->socid = GETPOST('socid', 'int'); @@ -603,6 +606,14 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { // Label print ''.$langs->trans("Label").''; + // Parent + if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) { + print ''.$langs->trans("Parent").''; + print img_picto('', 'project', 'class="pictofixedwidth"'); + $formproject->select_projects(-1, '', 'fk_project', 64, 0, 1, 1, 0, 0, 0, '', 0, 0, '', '', ''); + print ''; + } + // Usage (opp, task, bill time, ...) if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) { print ''; @@ -970,6 +981,14 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { print ajax_combobox('status'); print ''; + // Parent + if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) { + print ''.$langs->trans("Parent").''; + print img_picto('', 'project', 'class="pictofixedwidth"'); + $formproject->select_projects(-1, $object->fk_project, 'fk_project', 64, 0, 1, 1, 0, 0, 0, '', 0, 0, '', '', ''); + print ''; + } + // Usage if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) { print ''; @@ -1246,6 +1265,14 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } + // Parent + if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) { + if (!empty($object->fk_project) && $object->fk_project) { + $parent = new Project($db); + $parent->fetch($object->fk_project); + $morehtmlref .= $langs->trans("Child of").' '.$parent->getNomUrl(1, 'project').' '.$parent->title; + } + } $morehtmlref .= ''; // Define a complementary filter for search of next/prev ref. @@ -1618,6 +1645,41 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { print '
'; print ''; // ancre + if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) { + /* + * Sub-projects (children) + */ + $children = $object->getChildren(); + if ($children) { + print ''; + print '
'; + print '
'.$langs->trans('Sub-projects').'
'; + print '
'; + + print '
'; + print ''; + print ''; + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', '', '', '', '', '', '', 1); + print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', '', '', '', '', '', '', 1); + print getTitleFieldOfList('Status', 0, $_SERVER["PHP_SELF"], '', '', '', '', '', '', '', 1); + print ''; + print "\n"; + + $subproject = new Project($db); + foreach ($children as $child) { + $subproject->fetch($child->rowid); + print ''; + print ''; + print ''; + print ''; + print ''; + } + + print '
'.$subproject->getNomUrl(1, 'project').''.$child->title.''.$subproject->getLibStatut(5).'
'; + print '
'; + } + } + /* * Generated documents */ diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 076dae11a00..ac13af7d25a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -82,6 +82,11 @@ class Project extends CommonObject */ protected $table_ref_field = 'ref'; + /** + * @var int parent project + */ + public $fk_project; + /** * @var string description */ @@ -291,6 +296,7 @@ class Project extends CommonObject */ public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'fk_project' =>array('type'=>'integer', 'label'=>'Parent', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'position'=>12), 'ref' =>array('type'=>'varchar(50)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'showoncombobox'=>1, 'position'=>15, 'searchall'=>1), 'title' =>array('type'=>'varchar(255)', 'label'=>'ProjectLabel', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>17, 'showoncombobox'=>2, 'searchall'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>3, 'notnull'=>1, 'position'=>19), @@ -426,6 +432,7 @@ class Project extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet ("; $sql .= "ref"; + $sql .= ", fk_project"; $sql .= ", title"; $sql .= ", description"; $sql .= ", fk_soc"; @@ -458,6 +465,7 @@ class Project extends CommonObject $sql .= ", ip"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->ref)."'"; + $sql .= ", ".($this->fk_project ? ((int) $this->fk_project) : "null"); $sql .= ", '".$this->db->escape($this->title)."'"; $sql .= ", '".$this->db->escape($this->description)."'"; $sql .= ", ".($this->socid > 0 ? $this->socid : "null"); @@ -570,6 +578,7 @@ class Project extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."projet SET"; $sql .= " ref='".$this->db->escape($this->ref)."'"; + $sql .= ", fk_project=".($this->fk_project ? ((int) $this->fk_project) : "null"); $sql .= ", title = '".$this->db->escape($this->title)."'"; $sql .= ", description = '".$this->db->escape($this->description)."'"; $sql .= ", fk_soc = ".($this->socid > 0 ? $this->socid : "null"); @@ -680,7 +689,7 @@ class Project extends CommonObject return -1; } - $sql = "SELECT rowid, entity, ref, title, description, public, datec, opp_amount, budget_amount,"; + $sql = "SELECT rowid, entity, fk_project, ref, title, description, public, datec, opp_amount, budget_amount,"; $sql .= " tms, dateo as date_start, datee as date_end, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,"; $sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid,"; $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth, max_attendees, date_start_event, date_end_event, location, extraparams"; @@ -709,6 +718,7 @@ class Project extends CommonObject $this->id = $obj->rowid; $this->entity = $obj->entity; $this->ref = $obj->ref; + $this->fk_project = $obj->fk_project; $this->title = $obj->title; $this->description = $obj->description; $this->date_c = $this->db->jdate($obj->datec); @@ -2480,4 +2490,31 @@ class Project extends CommonObject $return .= '
'; return $return; } + + /** + * Return array of sub-projects of the current project + * + * @return array Children of this project as objects with rowid & title as members + */ + public function getChildren() + { + $children = []; + $sql = 'SELECT rowid,title'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'projet'; + $sql .= ' WHERE fk_project = '.((int) $this->id); + $sql .= ' ORDER BY title'; + $result = $this->db->query($sql); + if ($result) { + $n = $this->db->num_rows($result); + while ($n) { + $children[] = $this->db->fetch_object($result); + $n--; + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + + return $children; + } }