diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php new file mode 100644 index 00000000000..ecb8a0da6f9 --- /dev/null +++ b/htdocs/core/class/html.formcontract.class.php @@ -0,0 +1,144 @@ + + * + * 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 http://www.gnu.org/ + */ + +/** + * \file htdocs/core/class/html.formcontract.class.php + * \ingroup core + * \brief File of class with all html predefined components + */ + +/** + * Class to manage generation of HTML components for bank module + */ +class Formcontract +{ + var $db; + var $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + + /** + * Show a combo list with contracts qualified for a third party + * + * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) + * @param int $selected Id contract preselected + * @param string $htmlname Nom de la zone html + * @param int $maxlength Maximum length of label + * @return int Nbre of project if OK, <0 if KO + */ + function select_contract($socid=-1, $selected='', $htmlname='contrattid', $maxlength=16) + { + global $db,$user,$conf,$langs; + + $hideunselectables = false; + if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + + // Search all contacts + $sql = 'SELECT c.rowid, c.ref, c.note, c.fk_soc, c.statut'; + $sql.= ' FROM '.MAIN_DB_PREFIX .'contrat as c'; + $sql.= " WHERE c.entity = ".$conf->entity; + //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; + if ($socid == 0) + $sql.= " AND (c.fk_soc=0 OR c.fk_soc IS NULL)"; + else + $sql.= " AND c.fk_soc=".$socid; + $sql.= " ORDER BY c.note ASC"; + + dol_syslog("contact.lib::select_contrats sql=".$sql); + $resql=$db->query($sql); + if ($resql) + { + print ''; + $db->free($resql); + return $num; + } + else + { + dol_print_error($db); + return -1; + } + } +} +?>