diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index ecc8ec22660..0f61ecada43 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1415,7 +1415,7 @@ if ($action == 'create') { } - $arrayothercontracts = $object->getListOfContracts('others'); + $arrayothercontracts = $object->getListOfContracts('others'); // array or -1 if technical error /* * Lines of contracts @@ -1544,9 +1544,9 @@ if ($action == 'create') { print ''.price($objp->pa_ht).''; } - // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) + // Icon move, update et delete (status contract 0=draft,1=validated,2=closed) print ''; - if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { + if ($user->rights->contrat->creer && is_array($arrayothercontracts) && count($arrayothercontracts) && ($object->statut >= 0)) { print ''; print ''; print img_picto($langs->trans("MoveToAnotherContract"), 'uparrow'); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ca52dcc6c91..ee59a5465dc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2126,7 +2126,7 @@ class Contrat extends CommonObject } /** - * Return list of other contracts for same company than current contract + * Return list of other contracts for the same company than current contract * * @param string $option 'all' or 'others' * @param array $status sort contracts having these status @@ -2138,7 +2138,7 @@ class Contrat extends CommonObject { $tab = array(); - $sql = "SELECT c.rowid, c.ref"; + $sql = "SELECT c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; if (!empty($product_categories)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON cd.fk_contrat = c.rowid"; @@ -2159,12 +2159,12 @@ class Contrat extends CommonObject $obj = $this->db->fetch_object($resql); $contrat = new Contrat($this->db); $contrat->fetch($obj->rowid); - $tab[] = $contrat; + $tab[$contrat->id] = $contrat; $i++; } return $tab; } else { - $this->error = $this->db->error(); + $this->error = $this->db->lasterror(); return -1; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2330ad56705..eafc2e9e571 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4901,9 +4901,11 @@ class Form * @param int|string $height Force height of box (0 = auto) * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a
section. + * @param string $labelbuttonyes Label for Yes + * @param string $labelbuttonno Label for No * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ - public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) + public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes = 'Yes', $labelbuttonno = 'No') { global $langs, $conf; @@ -5012,7 +5014,7 @@ class Form $more .= ' checked="checked"'; } $more .= ' /> '; - $more .= ''; + $more .= ''; $more .= ''."\n"; $i++; } @@ -5118,6 +5120,7 @@ class Form $(this).parent().find("button.ui-button:eq(2)").focus(); },'; } + $formconfirm .= ' resizable: false, height: "'.$height.'", @@ -5125,7 +5128,7 @@ class Form modal: true, closeOnEscape: false, buttons: { - "'.dol_escape_js($langs->transnoentities("Yes")).'": function() { + "'.dol_escape_js($langs->transnoentities($labelbuttonyes)).'": function() { var options = "&token='.urlencode(newToken()).'"; var inputok = '.json_encode($inputok).'; /* List of fields into form */ var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'"; @@ -5148,7 +5151,7 @@ class Form if (pageyes.length > 0) { location.href = urljump; } $(this).dialog("close"); }, - "'.dol_escape_js($langs->transnoentities("No")).'": function() { + "'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() { var options = "&token='.urlencode(newToken()).'"; var inputko = '.json_encode($inputko).'; /* List of fields into form */ var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'"; @@ -5213,7 +5216,7 @@ class Form $formconfirm .= ''; $formconfirm .= ''.$question.''; $formconfirm .= ''; - $formconfirm .= $this->selectyesno("confirm", $newselectedchoice, 0, false, 0, 0, 'marginleftonly marginrightonly'); + $formconfirm .= $this->selectyesno("confirm", $newselectedchoice, 0, false, 0, 0, 'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno); $formconfirm .= ''; $formconfirm .= ''; $formconfirm .= ''."\n"; @@ -8844,9 +8847,11 @@ class Form * @param int $useempty 1=Add empty line * @param int $addjscombo 1=Add js beautifier on combo box * @param string $morecss More CSS - * @return string See option + * @param string $labelyes Label for Yes + * @param string $labelno Label for No + * @return string See option */ - public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0, $addjscombo = 0, $morecss = '') + public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0, $addjscombo = 0, $morecss = '', $labelyes = 'Yes', $labelno = 'No') { global $langs; @@ -8857,6 +8862,7 @@ class Form $no = "0"; } + $disabled = ($disabled ? ' disabled' : ''); $resultyesno = ''."\n";