34require 
'../main.inc.php';
 
   35require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
 
   36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
 
   37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
 
   39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
 
   40require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
 
   41if (isModEnabled(
"categorie")) {
 
   42  require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
 
   46$langs->loadLangs(array(
'contracts', 
'products', 
'companies', 
'compta'));
 
   48$action = 
GETPOST(
'action', 
'aZ09');
 
   49$massaction = 
GETPOST(
'massaction', 
'alpha');
 
   50$show_files = 
GETPOST(
'show_files', 
'int');
 
   51$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   52$toselect = 
GETPOST(
'toselect', 
'array');
 
   53$contextpage = 
GETPOST(
'contextpage', 
'aZ') ? 
GETPOST(
'contextpage', 
'aZ') : 
'contractlist'; 
 
   54$optioncss = 
GETPOST(
'optioncss', 
'alpha');
 
   55$mode = 
GETPOST(
'mode', 
'alpha');
 
   57$search_name = 
GETPOST(
'search_name', 
'alpha');
 
   58$search_email = 
GETPOST(
'search_email', 
'alpha');
 
   59$search_town = 
GETPOST(
'search_town', 
'alpha');
 
   60$search_zip = 
GETPOST(
'search_zip', 
'alpha');
 
   61$search_state = 
GETPOST(
"search_state", 
'alpha');
 
   62$search_country = 
GETPOST(
"search_country", 
'int');
 
   63$search_type_thirdparty = 
GETPOST(
"search_type_thirdparty", 
'int');
 
   64$search_contract = 
GETPOST(
'search_contract', 
'alpha');
 
   65$search_ref_customer = 
GETPOST(
'search_ref_customer', 
'alpha');
 
   66$search_ref_supplier = 
GETPOST(
'search_ref_supplier', 
'alpha');
 
   67$search_all = (
GETPOST(
'search_all', 
'alphanohtml') != 
'') ? 
GETPOST(
'search_all', 
'alphanohtml') : 
GETPOST(
'sall', 
'alphanohtml');
 
   68$search_status = 
GETPOST(
'search_status', 
'alpha');
 
   69$socid = 
GETPOST(
'socid', 
'int');
 
   70$search_user = 
GETPOST(
'search_user', 
'int');
 
   71$search_sale = 
GETPOST(
'search_sale', 
'int');
 
   72$search_product_category = 
GETPOST(
'search_product_category', 
'int');
 
   73$search_dfmonth = 
GETPOST(
'search_dfmonth', 
'int');
 
   74$search_dfyear = 
GETPOST(
'search_dfyear', 
'int');
 
   75$search_op2df = 
GETPOST(
'search_op2df', 
'alpha');
 
   76$search_date_startday = 
GETPOST(
'search_date_startday', 
'int');
 
   77$search_date_startmonth = 
GETPOST(
'search_date_startmonth', 
'int');
 
   78$search_date_startyear = 
GETPOST(
'search_date_startyear', 
'int');
 
   79$search_date_endday = 
GETPOST(
'search_date_endday', 
'int');
 
   80$search_date_endmonth = 
GETPOST(
'search_date_endmonth', 
'int');
 
   81$search_date_endyear = 
GETPOST(
'search_date_endyear', 
'int');
 
   82$search_date_start = 
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); 
 
   83$search_date_end = 
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
 
   84$searchCategoryCustomerOperator = 0;
 
   85if (GETPOSTISSET(
'formfilteraction')) {
 
   86  $searchCategoryCustomerOperator = 
GETPOST(
'search_category_customer_operator', 
'int');
 
   88  $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
 
   90$searchCategoryCustomerList = 
GETPOST(
'search_category_customer_list', 
'array');
 
   92$search_date_creation_startmonth = 
GETPOST(
'search_date_creation_startmonth', 
'int');
 
   93$search_date_creation_startyear = 
GETPOST(
'search_date_creation_startyear', 
'int');
 
   94$search_date_creation_startday = 
GETPOST(
'search_date_creation_startday', 
'int');
 
   95$search_date_creation_start = 
dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); 
 
   96$search_date_creation_endmonth = 
GETPOST(
'search_date_creation_endmonth', 
'int');
 
   97$search_date_creation_endyear = 
GETPOST(
'search_date_creation_endyear', 
'int');
 
   98$search_date_creation_endday = 
GETPOST(
'search_date_creation_endday', 
'int');
 
   99$search_date_creation_end = 
dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);  
 
  101$search_date_modif_startmonth = 
GETPOST(
'search_date_modif_startmonth', 
'int');
 
  102$search_date_modif_startyear = 
GETPOST(
'search_date_modif_startyear', 
'int');
 
  103$search_date_modif_startday = 
GETPOST(
'search_date_modif_startday', 
'int');
 
  104$search_date_modif_start = 
dol_mktime(0, 0, 0, $search_date_modif_startmonth, $search_date_modif_startday, $search_date_modif_startyear); 
 
  105$search_date_modif_endmonth = 
GETPOST(
'search_date_modif_endmonth', 
'int');
 
  106$search_date_modif_endyear = 
GETPOST(
'search_date_modif_endyear', 
'int');
 
  107$search_date_modif_endday = 
GETPOST(
'search_date_modif_endday', 
'int');
 
  108$search_date_modif_end = 
dol_mktime(23, 59, 59, $search_date_modif_endmonth, $search_date_modif_endday, $search_date_modif_endyear);  
 
  111$limit = 
GETPOST(
'limit', 
'int') ? 
GETPOST(
'limit', 
'int') : $conf->liste_limit;
 
  112$sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
  113$sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
  114$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) : 
GETPOST(
"page", 
'int');
 
  115if (empty($page) || $page < 0 || 
GETPOST(
'button_search', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')) {
 
  119$offset = $limit * $page;
 
  120$pageprev = $page - 1;
 
  121$pagenext = $page + 1;
 
  123  $sortfield = 
'c.ref';
 
  132  $socid = $user->socid;
 
  136$diroutputmassaction = $conf->contrat->dir_output.
'/temp/massgeneration/'.$user->id;
 
  138$staticcontrat = 
new Contrat($db);
 
  141if ($search_status == 
'') {
 
  147$hookmanager->initHooks(array(
'contractlist'));
 
  151$extrafields->fetch_name_optionals_label($object->table_element);
 
  153$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, 
'', 
'search_');
 
  155$fieldstosearchall = array();
 
  156foreach ($object->fields as $key => $val) {
 
  157  if (!empty($val[
'searchall'])) {
 
  158    $fieldstosearchall[
'c.'.$key] = $val[
'label'];
 
  161$fieldstosearchall[
"s.nom"] = 
"ThirdParty";
 
  162if (empty($user->socid)) {
 
  163  $fieldstosearchall[
"c.note_private"] = 
"NotePrivate";
 
  165$parameters = array(
'fieldstosearchall'=>$fieldstosearchall);
 
  166$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action); 
 
  168  $fieldstosearchall = $hookmanager->resArray[
'fieldstosearchall'];
 
  169} elseif ($reshook == 0) {
 
  170  if (!empty($hookmanager->resArray[
'fieldstosearchall'])) {
 
  171    $fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray[
'fieldstosearchall']);
 
  176  'c.ref'=>array(
'label'=>$langs->trans(
"Ref"), 
'checked'=>1, 
'position'=>10),
 
  177  'c.ref_customer'=>array(
'label'=>$langs->trans(
"RefCustomer"), 
'checked'=>1, 
'position'=>12),
 
  178  'c.ref_supplier'=>array(
'label'=>$langs->trans(
"RefSupplier"), 
'checked'=>1, 
'position'=>14),
 
  179  's.nom'=>array(
'label'=>$langs->trans(
"ThirdParty"), 
'checked'=>1, 
'position'=>30),
 
  180  's.email'=>array(
'label'=>$langs->trans(
"ThirdPartyEmail"), 
'checked'=>0, 
'position'=>30),
 
  181  's.town'=>array(
'label'=>$langs->trans(
"Town"), 
'checked'=>0, 
'position'=>31),
 
  182  's.zip'=>array(
'label'=>$langs->trans(
"Zip"), 
'checked'=>1, 
'position'=>32),
 
  183  'state.nom'=>array(
'label'=>$langs->trans(
"StateShort"), 
'checked'=>0, 
'position'=>33),
 
  184  'country.code_iso'=>array(
'label'=>$langs->trans(
"Country"), 
'checked'=>0, 
'position'=>34),
 
  185  'sale_representative'=>array(
'label'=>$langs->trans(
"SaleRepresentativesOfThirdParty"), 
'checked'=>-1, 
'position'=>80),
 
  186  'c.date_contrat'=>array(
'label'=>$langs->trans(
"DateContract"), 
'checked'=>1, 
'position'=>45),
 
  187  'c.datec'=>array(
'label'=>$langs->trans(
"DateCreation"), 
'checked'=>0, 
'position'=>500),
 
  188  'c.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"), 
'checked'=>0, 
'position'=>500),
 
  189  'lower_planned_end_date'=>array(
'label'=>$langs->trans(
"LowerDateEndPlannedShort"), 
'checked'=>1, 
'position'=>900, 
'help'=>$langs->trans(
"LowerDateEndPlannedShort")),
 
  190  'status'=>array(
'label'=>$langs->trans(
"Status"), 
'checked'=>1, 
'position'=>1000),
 
  193include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
 
  198if (!$user->hasRight(
'societe', 
'client', 
'voir')) {
 
  199  $search_sale = $user->id;
 
  202$permissiontoread = $user->hasRight(
'contrat', 
'lire');
 
  203$permissiontoadd = $user->hasRight(
'contrat', 
'creer');
 
  204$permissiontodelete = $user->hasRight(
'contrat', 
'supprimer');
 
  214if (
GETPOST(
'cancel', 
'alpha')) {
 
  218if (!
GETPOST(
'confirmmassaction', 
'alpha') && $massaction != 
'presend' && $massaction != 
'confirm_presend') {
 
  222$parameters = array(
'socid'=>$socid);
 
  223$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
  228include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
 
  230if (
GETPOST(
'button_removefilter_x', 
'alpha') || 
GETPOST(
'button_removefilter.x', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')) { 
 
  231  $search_dfmonth = 
'';
 
  240  $search_country = 
'';
 
  241  $search_contract = 
"";
 
  242  $search_ref_customer = 
"";
 
  243  $search_ref_supplier = 
"";
 
  246  $search_product_category = 
'';
 
  247  $search_date_startday = 
'';
 
  248  $search_date_startmonth = 
'';
 
  249  $search_date_startyear = 
'';
 
  250  $search_date_endday = 
'';
 
  251  $search_date_endmonth = 
'';
 
  252  $search_date_endyear = 
'';
 
  253  $search_date_start = 
'';
 
  254  $search_date_end = 
'';
 
  256  $search_date_creation_startmonth = 
"";
 
  257  $search_date_creation_startyear = 
"";
 
  258  $search_date_creation_startday = 
"";
 
  259  $search_date_creation_start = 
"";
 
  260  $search_date_creation_endmonth = 
"";
 
  261  $search_date_creation_endyear = 
"";
 
  262  $search_date_creation_endday = 
"";
 
  263  $search_date_creation_end = 
"";
 
  264  $search_date_modif_startmonth = 
"";
 
  265  $search_date_modif_startyear = 
"";
 
  266  $search_date_modif_startday = 
"";
 
  267  $search_date_modif_start = 
"";
 
  268  $search_date_modif_endmonth = 
"";
 
  269  $search_date_modif_endyear = 
"";
 
  270  $search_date_modif_endday = 
"";
 
  271  $search_date_modif_end = 
"";
 
  274  $search_type_thirdparty = 
'';
 
  275  $searchCategoryCustomerList = array();
 
  276  $search_array_options = array();
 
  279if (empty($reshook)) {
 
  280  $objectclass = 
'Contrat';
 
  281  $objectlabel = 
'Contracts';
 
  282  $uploaddir = $conf->contrat->dir_output;
 
  283  include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
 
  291$form = 
new Form($db);
 
  296$contracttmp = 
new Contrat($db);
 
  303$sql .= 
" c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity,";
 
  304$sql .= 
' s.rowid as socid, s.nom as name, s.name_alias, s.email, s.town, s.zip, s.fk_pays as country_id, s.client, s.code_client, s.status as company_status, s.logo as company_logo,';
 
  305$sql .= 
" typent.code as typent_code,";
 
  306$sql .= 
" state.code_departement as state_code, state.nom as state_name,";
 
  307$sql .= 
" MIN(".$db->ifsql(
"cd.statut=4", 
"cd.date_fin_validite", 
"null").
") as lower_planned_end_date,";
 
  308$sql .= 
" SUM(".$db->ifsql(
"cd.statut=0", 1, 0).
') as nb_initial,';
 
  309$sql .= 
" SUM(".$db->ifsql(
"cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now).
"')", 1, 0).
') as nb_running,';
 
  310$sql .= 
" SUM(".$db->ifsql(
"cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now).
"')", 1, 0).
') as nb_expired,';
 
  311$sql .= 
" SUM(".$db->ifsql(
"cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay).
"')", 1, 0).
') as nb_late,';
 
  312$sql .= 
" SUM(".$db->ifsql(
"cd.statut=5", 1, 0).
') as nb_closed';
 
  314if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
 
  315  foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
 
  316    $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] != 
'separate' ? 
", ef.".$key.
" as options_".$key : 
'');
 
  320$parameters = array();
 
  321$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action); 
 
  322$sql .= $hookmanager->resPrint;
 
  323$sql = preg_replace(
'/,\s*$/', 
'', $sql);
 
  327$sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s";
 
  328$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
 
  329$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
 
  330$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
 
  331$sql .= 
", ".MAIN_DB_PREFIX.
"contrat as c";
 
  332if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
 
  333  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (c.rowid = ef.fk_object)";
 
  335$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
 
  336if ($search_user > 0) {
 
  337  $sql .= 
", ".MAIN_DB_PREFIX.
"element_contact as ec";
 
  338  $sql .= 
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
 
  340$sql .= 
" WHERE c.fk_soc = s.rowid ";
 
  341$sql .= 
' AND c.entity IN ('.getEntity(
'contract').
')';
 
  342if ($search_type_thirdparty != 
'' && $search_type_thirdparty > 0) {
 
  343  $sql .= 
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
 
  346  $sql .= 
" AND s.rowid = ".((int) $socid);
 
  348if ($search_date_start) {
 
  349  $sql .= 
" AND c.date_contrat >= '".$db->idate($search_date_start).
"'";
 
  351if ($search_date_end) {
 
  352  $sql .= 
" AND c.date_contrat <= '".$db->idate($search_date_end).
"'";
 
  360if ($search_contract) {
 
  361  $sql .= 
natural_search(array(
'c.rowid', 
'c.ref'), $search_contract);
 
  363if (!empty($search_ref_customer)) {
 
  364  $sql .= 
natural_search(array(
'c.ref_customer'), $search_ref_customer);
 
  366if (!empty($search_ref_supplier)) {
 
  367  $sql .= 
natural_search(array(
'c.ref_supplier'), $search_ref_supplier);
 
  375if ($search_country && $search_country != 
'-1') {
 
  376  $sql .= 
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
 
  382  $sql .= 
natural_search(array_keys($fieldstosearchall), $search_all);
 
  384if ($search_user > 0) {
 
  385  $sql .= 
" AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
 
  388if ($search_sale && $search_sale != 
'-1') {
 
  389  if ($search_sale == -2) {
 
  390    $sql .= 
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
 
  391  } elseif ($search_sale > 0) {
 
  392    $sql .= 
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
 
  396$searchCategoryProductOperator = -1;
 
  397$searchCategoryProductList = array($search_product_category);
 
  398if (!empty($searchCategoryProductList)) {
 
  399  $searchCategoryProductSqlList = array();
 
  400  $listofcategoryid = 
'';
 
  401  foreach ($searchCategoryProductList as $searchCategoryProduct) {
 
  402    if (intval($searchCategoryProduct) == -2) {
 
  403      $searchCategoryProductSqlList[] = 
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product)";
 
  404    } elseif (intval($searchCategoryProduct) > 0) {
 
  405      if ($searchCategoryProductOperator == 0) {
 
  406        $searchCategoryProductSqlList[] = 
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
 
  408        $listofcategoryid .= ($listofcategoryid ? 
', ' : 
'') .((
int) $searchCategoryProduct);
 
  412  if ($listofcategoryid) {
 
  413    $searchCategoryProductSqlList[] = 
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
 
  415  if ($searchCategoryProductOperator == 1) {
 
  416    if (!empty($searchCategoryProductSqlList)) {
 
  417      $sql .= 
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
 
  420    if (!empty($searchCategoryProductSqlList)) {
 
  421      $sql .= 
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
 
  425$searchCategoryCustomerSqlList = array();
 
  426if ($searchCategoryCustomerOperator == 1) {
 
  427  $existsCategoryCustomerList = array();
 
  428  foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
 
  429    if (intval($searchCategoryCustomer) == -2) {
 
  430      $sqlCategoryCustomerNotExists  = 
" NOT EXISTS (";
 
  431      $sqlCategoryCustomerNotExists .= 
" SELECT cat_cus.fk_soc";
 
  432      $sqlCategoryCustomerNotExists .= 
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
 
  433      $sqlCategoryCustomerNotExists .= 
" WHERE cat_cus.fk_soc = s.rowid";
 
  434      $sqlCategoryCustomerNotExists .= 
" )";
 
  435      $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
 
  436    } elseif (intval($searchCategoryCustomer) > 0) {
 
  437      $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
 
  440  if (!empty($existsCategoryCustomerList)) {
 
  441    $sqlCategoryCustomerExists = 
" EXISTS (";
 
  442    $sqlCategoryCustomerExists .= 
" SELECT cat_cus.fk_soc";
 
  443    $sqlCategoryCustomerExists .= 
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
 
  444    $sqlCategoryCustomerExists .= 
" WHERE cat_cus.fk_soc = s.rowid";
 
  445    $sqlCategoryCustomerExists .= 
" AND cat_cus.fk_categorie IN (".$db->sanitize(implode(
',', $existsCategoryCustomerList)).
")";
 
  446    $sqlCategoryCustomerExists .= 
" )";
 
  447    $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
 
  449  if (!empty($searchCategoryCustomerSqlList)) {
 
  450    $sql .= 
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
 
  453  foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
 
  454    if (intval($searchCategoryCustomer) == -2) {
 
  455      $sqlCategoryCustomerNotExists = 
" NOT EXISTS (";
 
  456      $sqlCategoryCustomerNotExists .= 
" SELECT cat_cus.fk_soc";
 
  457      $sqlCategoryCustomerNotExists .= 
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
 
  458      $sqlCategoryCustomerNotExists .= 
" WHERE cat_cus.fk_soc = s.rowid";
 
  459      $sqlCategoryCustomerNotExists .= 
" )";
 
  460      $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
 
  461    } elseif (intval($searchCategoryCustomer) > 0) {
 
  462      $searchCategoryCustomerSqlList[] = 
"s.rowid IN (SELECT fk_soc FROM ".$db->prefix().
"categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).
")";
 
  465  if (!empty($searchCategoryCustomerSqlList)) {
 
  466    $sql .= 
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
 
  470if ($search_date_creation_start) {
 
  471  $sql .= 
" AND c.datec >= '".$db->idate($search_date_creation_start).
"'";
 
  473if ($search_date_creation_end) {
 
  474  $sql .= 
" AND c.datec <= '".$db->idate($search_date_creation_end).
"'";
 
  477if ($search_date_modif_start) {
 
  478  $sql .= 
" AND c.tms >= '".$db->idate($search_date_modif_start).
"'";
 
  480if ($search_date_modif_end) {
 
  481  $sql .= 
" AND c.tms <= '".$db->idate($search_date_modif_end).
"'";
 
  485include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
 
  487$parameters = array();
 
  488$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action); 
 
  489$sql .= $hookmanager->resPrint;
 
  490$sql .= 
" GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity,";
 
  491$sql .= 
' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.status, s.logo,';
 
  492$sql .= 
" typent.code,";
 
  493$sql .= 
" state.code_departement, state.nom";
 
  495if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
 
  496  foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
 
  497    $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] != 
'separate' ? 
", ef.".$key : 
'');
 
  501$parameters = array(
'search_dfyear' => $search_dfyear, 
'search_op2df'=>$search_op2df);
 
  502$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object); 
 
  503$sql .= $hookmanager->resPrint;
 
  505$parameters = array(
'search_dfyear' => $search_dfyear, 
'search_op2df'=>$search_op2df);
 
  506$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action); 
 
  507if (empty($reshook)) {
 
  508  if ($search_dfyear > 0 && $search_op2df) {
 
  509    if ($search_op2df == 
'<=') {
 
  510      $sql .= 
" HAVING MIN(".$db->ifsql(
"cd.statut=4", 
"cd.date_fin_validite", 
"null").
") <= '".$db->idate(
dol_get_last_day($search_dfyear, $search_dfmonth, 
false)).
"'";
 
  511    } elseif ($search_op2df == 
'>=') {
 
  512      $sql .= 
" HAVING MIN(".$db->ifsql(
"cd.statut=4", 
"cd.date_fin_validite", 
"null").
") >= '".$db->idate(
dol_get_first_day($search_dfyear, $search_dfmonth, 
false)).
"'";
 
  514      $sql .= 
" HAVING MIN(".$db->ifsql(
"cd.statut=4", 
"cd.date_fin_validite", 
"null").
") <= '".$db->idate(
dol_get_last_day($search_dfyear, $search_dfmonth, 
false)).
"' AND MIN(".$db->ifsql(
"cd.statut=4", 
"cd.date_fin_validite", 
"null").
") >= '".$db->idate(
dol_get_first_day($search_dfyear, $search_dfmonth, 
false)).
"'";
 
  518$sql .= $hookmanager->resPrint;
 
  521$nbtotalofrecords = 
'';
 
  526  if ($search_dfyear > 0 && $search_op2df) {
 
  527    $resql = $db->query($sql, 0, 
'auto', 1);
 
  528    while ($db->fetch_object($resql)) {
 
  529      if (empty($nbtotalofrecords)) {
 
  530        $nbtotalofrecords = 1;    
 
  537    $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields, 
'/').
'/', 
'SELECT COUNT(*) as nbtotalofrecords', $sql);
 
  538    $sqlforcount = preg_replace(
'/LEFT JOIN '.MAIN_DB_PREFIX.
'contratdet as cd ON c.rowid = cd.fk_contrat /', 
'', $sqlforcount);
 
  539    $sqlforcount = preg_replace(
'/GROUP BY.*$/', 
'', $sqlforcount);
 
  541    $resql = $db->query($sqlforcount);
 
  543      $objforcount = $db->fetch_object($resql);
 
  544      $nbtotalofrecords = $objforcount->nbtotalofrecords;
 
  550  if (($page * $limit) > $nbtotalofrecords) { 
 
  558$sql .= $db->order($sortfield, $sortorder);
 
  560  $sql .= $db->plimit($limit + 1, $offset);
 
  563$resql = $db->query($sql);
 
  569$num = $db->num_rows($resql);
 
  572if ($num == 1 && 
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
 
  573  $obj = $db->fetch_object($resql);
 
  575  header(
"Location: ".DOL_URL_ROOT.
'/contrat/card.php?id='.$id);
 
  583llxHeader(
'', $langs->trans(
"Contracts"));
 
  587$arrayofselected = is_array($toselect) ? $toselect : array();
 
  592  if (empty($search_name)) {
 
  593    $search_name = $soc->name;
 
  599  $param .= 
'&mode='.urlencode($mode);
 
  601if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
 
  602  $param .= 
'&contextpage='.urlencode($contextpage);
 
  604if ($limit > 0 && $limit != $conf->liste_limit) {
 
  605  $param .= 
'&limit='.((int) $limit);
 
  607if ($search_all != 
'') {
 
  608  $param .= 
'&search_all='.urlencode($search_all);
 
  610if ($search_contract != 
'') {
 
  611  $param .= 
'&search_contract='.urlencode($search_contract);
 
  613if ($search_name != 
'') {
 
  614  $param .= 
'&search_name='.urlencode($search_name);
 
  616if ($search_email != 
'') {
 
  617  $param .= 
'&search_email='.urlencode($search_email);
 
  619if ($search_ref_customer != 
'') {
 
  620  $param .= 
'&search_ref_customer='.urlencode($search_ref_customer);
 
  622if ($search_ref_supplier != 
'') {
 
  623  $param .= 
'&search_ref_supplier='.urlencode($search_ref_supplier);
 
  625if ($search_op2df != 
'') {
 
  626  $param .= 
'&search_op2df='.urlencode($search_op2df);
 
  628if ($search_date_creation_startmonth) {
 
  629  $param .= 
'&search_date_creation_startmonth='.urlencode($search_date_creation_startmonth);
 
  631if ($search_date_creation_startyear) {
 
  632  $param .= 
'&search_date_creation_startyear='.urlencode($search_date_creation_startyear);
 
  634if ($search_date_creation_startday) {
 
  635  $param .= 
'&search_date_creation_startday='.urlencode($search_date_creation_startday);
 
  637if ($search_date_creation_start) {
 
  638  $param .= 
'&search_date_creation_start='.urlencode($search_date_creation_start);
 
  640if ($search_date_creation_endmonth) {
 
  641  $param .= 
'&search_date_creation_endmonth='.urlencode($search_date_creation_endmonth);
 
  643if ($search_date_creation_endyear) {
 
  644  $param .= 
'&search_date_creation_endyear='.urlencode($search_date_creation_endyear);
 
  646if ($search_date_creation_endday) {
 
  647  $param .= 
'&search_date_creation_endday='.urlencode($search_date_creation_endday);
 
  649if ($search_date_creation_end) {
 
  650  $param .= 
'&search_date_creation_end='.urlencode($search_date_creation_end);
 
  652if ($search_date_modif_startmonth) {
 
  653  $param .= 
'&search_date_modif_startmonth='.urlencode($search_date_modif_startmonth);
 
  655if ($search_date_modif_startyear) {
 
  656  $param .= 
'&search_date_modif_startyear='.urlencode($search_date_modif_startyear);
 
  658if ($search_date_modif_startday) {
 
  659  $param .= 
'&search_date_modif_startday='.urlencode($search_date_modif_startday);
 
  661if ($search_date_modif_start) {
 
  662  $param .= 
'&search_date_modif_start='.urlencode($search_date_modif_start);
 
  664if ($search_date_modif_endmonth) {
 
  665  $param .= 
'&search_date_modif_endmonth='.urlencode($search_date_modif_endmonth);
 
  667if ($search_date_modif_endyear) {
 
  668  $param .= 
'&search_date_modif_endyear='.urlencode($search_date_modif_endyear);
 
  670if ($search_date_modif_endday) {
 
  671  $param .= 
'&search_date_modif_endday='.urlencode($search_date_modif_endday);
 
  673if ($search_date_modif_end) {
 
  674  $param .= 
'&search_date_modif_end=' . urlencode($search_date_modif_end);
 
  676if ($search_date_startday > 0) {
 
  677  $param .= 
'&search_date_startday='.urlencode($search_date_startday);
 
  679if ($search_date_startmonth > 0) {
 
  680  $param .= 
'&search_date_startmonth='.urlencode($search_date_startmonth);
 
  682if ($search_date_startyear > 0) {
 
  683  $param .= 
'&search_date_startyear='.urlencode($search_date_startyear);
 
  685if ($search_date_endday > 0) {
 
  686  $param .= 
'&search_date_endday='.urlencode($search_date_endday);
 
  688if ($search_date_endmonth > 0) {
 
  689  $param .= 
'&search_date_endmonth='.urlencode($search_date_endmonth);
 
  691if ($search_date_endyear > 0) {
 
  692  $param .= 
'&search_date_endyear='.urlencode($search_date_endyear);
 
  694if ($search_dfyear > 0) {
 
  695  $param .= 
'&search_dfyear='.urlencode($search_dfyear);
 
  697if ($search_dfmonth > 0) {
 
  698  $param .= 
'&search_dfmonth='.urlencode($search_dfmonth);
 
  700if ($search_sale > 0) {
 
  701  $param .= 
'&search_sale='.urlencode($search_sale);
 
  703if ($search_user > 0) {
 
  704  $param .= 
'&search_user='.urlencode($search_user);
 
  706if ($search_type_thirdparty > 0) {
 
  707  $param .= 
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
 
  709if ($search_country != 
'') {
 
  710  $param .= 
"&search_country=".urlencode($search_country);
 
  712if ($search_product_category > 0) {
 
  713  $param .= 
'&search_product_category='.urlencode($search_product_category);
 
  716  $param .= 
'&show_files='.urlencode($show_files);
 
  718if ($optioncss != 
'') {
 
  719  $param .= 
'&optioncss='.urlencode($optioncss);
 
  721foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
 
  722  $param .= 
"&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
 
  725include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
 
  728$arrayofmassactions = array(
 
  729  'generate_doc'=>
img_picto(
'', 
'pdf', 
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
 
  730  'builddoc'=>
img_picto(
'', 
'pdf', 
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
 
  731  'presend'=>
img_picto(
'', 
'email', 
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
 
  733if (!empty($permissiontodelete)) {
 
  734  $arrayofmassactions[
'predelete'] = 
img_picto(
'', 
'delete', 
'class="pictofixedwidth"').$langs->trans(
"Delete");
 
  736if (
GETPOST(
'nomassaction', 
'int') || in_array($massaction, array(
'presend', 
'predelete'))) {
 
  737  $arrayofmassactions = array();
 
  739$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
 
  741$url = DOL_URL_ROOT.
'/contrat/card.php?action=create';
 
  743  $url .= 
'&socid='.((int) $socid);
 
  746$newcardbutton .= 
dolGetButtonTitle($langs->trans(
'ViewList'), 
'', 
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/', 
'', $param), 
'', ((empty($mode) || $mode == 
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
 
  747$newcardbutton .= 
dolGetButtonTitle($langs->trans(
'ViewKanban'), 
'', 
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/', 
'', $param), 
'', ($mode == 
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
 
  749$newcardbutton .= 
dolGetButtonTitle($langs->trans(
'NewContractSubscription'), 
'', 
'fa fa-plus-circle', $url, 
'', $user->hasRight(
'contrat', 
'creer'));
 
  751print 
'<form method="POST" id="searchFormList" action="'.$_SERVER[
'PHP_SELF'].
'">'.
"\n";
 
  752if ($optioncss != 
'') {
 
  753  print 
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
 
  755print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  756print 
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
 
  757print 
'<input type="hidden" name="action" value="list">';
 
  758print 
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
 
  759print 
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
 
  760print 
'<input type="hidden" name="page" value="'.$page.
'">';
 
  761print 
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
 
  762print 
'<input type="hidden" name="page_y" value="">';
 
  763print 
'<input type="hidden" name="mode" value="'.$mode.
'">';
 
  765print_barre_liste($langs->trans(
"Contracts"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 
'contract', 0, $newcardbutton, 
'', $limit, 0, 0, 1);
 
  767$topicmail = 
"SendContractRef";
 
  768$modelmail = 
"contract";
 
  770$trackid = 
'con'.$object->id;
 
  771include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
 
  775  foreach ($fieldstosearchall as $key => $val) {
 
  776    $fieldstosearchall[$key] = $langs->trans($val);
 
  777    $setupstring .= $key.
"=".$val.
";";
 
  779  print 
'<!-- Search done like if CONTRACT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
 
  780  print 
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
 
  786if ($user->hasRight(
'user', 
'user', 
'lire')) {
 
  787  $langs->load(
"commercial");
 
  788  $moreforfilter .= 
'<div class="divsearchfield">';
 
  789  $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
 
  790  $moreforfilter .= 
img_picto($tmptitle, 
'user', 
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 
'search_sale', $user, 0, $tmptitle, 
'widthcentpercentminusx maxwidth300');
 
  791  $moreforfilter .= 
'</div>';
 
  794if ($user->hasRight(
'user', 
'user', 
'lire')) {
 
  795  $moreforfilter .= 
'<div class="divsearchfield">';
 
  796  $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
 
  797  $moreforfilter .= 
img_picto($tmptitle, 
'user', 
'class="pictofixedwidth"').$form->select_dolusers($search_user, 
'search_user', $tmptitle, 
'', 0, 
'', 
'', 0, 0, 0, 
'', 0, 
'', 
'widthcentpercentminusx maxwidth300');
 
  798  $moreforfilter .= 
'</div>';
 
  801if (isModEnabled(
'categorie') && $user->hasRight(
'categorie', 
'lire') && ($user->hasRight(
'produit', 
'lire') || $user->hasRight(
'service', 
'lire'))) {
 
  802  include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
 
  803  $moreforfilter .= 
'<div class="divsearchfield">';
 
  804  $tmptitle = $langs->trans(
'IncludingProductWithTag');
 
  805  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, 
null, 
'parent', 
null, 
null, 1);
 
  806  $moreforfilter .= 
img_picto($tmptitle, 
'category', 
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, 
'', 0, 0, 0, 0, 
'widthcentpercentminusx maxwidth300', 1);
 
  807  $moreforfilter .= 
'</div>';
 
  810if (
getDolGlobalString(
'MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST') && isModEnabled(
"categorie") && $user->hasRight(
'categorie', 
'lire')) {
 
  811  $moreforfilter .= 
'<div class="divsearchfield">';
 
  812  $tmptitle = $langs->transnoentities(
'CustomersProspectsCategoriesShort');
 
  813  $moreforfilter .= 
img_picto($tmptitle, 
'category', 
'class="pictofixedwidth"');
 
  814  $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, 
'', 
'', 64, 0, 1);
 
  815  $categoriesArr[-2] = 
'- '.$langs->trans(
'NotCategorized').
' -';
 
  816  $moreforfilter .= 
Form::multiselectarray(
'search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 
'minwidth300', 0, 0, 
'', 
'category', $tmptitle);
 
  817  $moreforfilter .= 
' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ? 
' checked="checked"' : 
'').
'/>';
 
  818  $moreforfilter .= $form->textwithpicto(
'', $langs->trans(
'UseOrOperatorForCategories') . 
' : ' . $tmptitle, 1, 
'help', 
'', 0, 2, 
'tooltip_cat_cus'); 
 
  819  $moreforfilter .= 
'</div>';
 
  822$parameters = array();
 
  823$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action); 
 
  824if (empty($reshook)) {
 
  825  $moreforfilter .= $hookmanager->resPrint;
 
  827  $moreforfilter = $hookmanager->resPrint;
 
  830if (!empty($moreforfilter)) {
 
  831  print 
'<div class="liste_titre liste_titre_bydiv centpercent">';
 
  832  print $moreforfilter;
 
  836$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
 
  837$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage, 
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN')); 
 
  838if ($massactionbutton) {
 
  839  $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
 
  842print 
'<div class="div-table-responsive">';
 
  843print 
'<table class="tagtable liste'.($moreforfilter ? 
" listwithfilterbefore" : 
"").
'">'.
"\n";
 
  847print 
'<tr class="liste_titre_filter">';
 
  850  print 
'<td class="liste_titre maxwidthsearch center">';
 
  851  $searchpicto = $form->showFilterButtons(
'left');
 
  855if (!empty($arrayfields[
'c.ref'][
'checked'])) {
 
  856  print 
'<td class="liste_titre">';
 
  857  print 
'<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
 
  860if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
 
  861  print 
'<td class="liste_titre">';
 
  862  print 
'<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
 
  865if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
 
  866  print 
'<td class="liste_titre">';
 
  867  print 
'<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).
'">';
 
  870if (!empty($arrayfields[
's.nom'][
'checked'])) {
 
  871  print 
'<td class="liste_titre">';
 
  872  print 
'<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
 
  875if (!empty($arrayfields[
's.email'][
'checked'])) {
 
  876  print 
'<td class="liste_titre">';
 
  877  print 
'<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
 
  881if (!empty($arrayfields[
's.town'][
'checked'])) {
 
  882  print 
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
 
  885if (!empty($arrayfields[
's.zip'][
'checked'])) {
 
  886  print 
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
 
  889if (!empty($arrayfields[
'state.nom'][
'checked'])) {
 
  890  print 
'<td class="liste_titre">';
 
  891  print 
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
 
  895if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
 
  896  print 
'<td class="liste_titre center">';
 
  897  print $form->select_country($search_country, 
'search_country', 
'', 0, 
'minwidth100imp maxwidth100');
 
  901if (!empty($arrayfields[
'typent.code'][
'checked'])) {
 
  902  print 
'<td class="liste_titre maxwidthonsmartphone center">';
 
  903  print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, 
'', 0, 0, 0, (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ? 
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 
'', 1);
 
  906if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
 
  907  print 
'<td class="liste_titre"></td>';
 
  909if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
 
  910  print 
'<td class="liste_titre center">';
 
  911  print 
'<div class="nowrapfordate">';
 
  912  print $form->selectDate($search_date_start ? $search_date_start : -1, 
'search_date_start', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'From'));
 
  914  print 
'<div class="nowrapfordate">';
 
  915  print $form->selectDate($search_date_end ? $search_date_end : -1, 
'search_date_end', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'to'));
 
  920include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
 
  923$parameters = array(
'arrayfields'=>$arrayfields);
 
  924$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action); 
 
  925print $hookmanager->resPrint;
 
  927if (!empty($arrayfields[
'c.datec'][
'checked'])) {
 
  928  print 
'<td class="liste_titre center nowraponall">';
 
  929  print 
'<div class="nowrapfordate">';
 
  930  print $form->selectDate($search_date_creation_start ? $search_date_creation_start : -1, 
'search_date_creation_start', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'From'));
 
  932  print 
'<div class="nowrapfordate">';
 
  933  print $form->selectDate($search_date_creation_end ? $search_date_creation_end : -1, 
'search_date_creation_end', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'to'));
 
  938if (!empty($arrayfields[
'c.tms'][
'checked'])) {
 
  939  print 
'<td class="liste_titre center nowraponall">';
 
  940  print 
'<div class="nowrapfordate">';
 
  941  print $form->selectDate($search_date_modif_start ? $search_date_modif_start : -1, 
'search_date_modif_start', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'From'));
 
  943  print 
'<div class="nowrapfordate">';
 
  944  print $form->selectDate($search_date_modif_end ? $search_date_modif_end : -1, 
'search_date_modif_end', 0, 0, 1, 
'', 1, 0, 0, 
'', 
'', 
'', 
'', 1, 
'', $langs->trans(
'to'));
 
  949if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
 
  950  print 
'<td class="liste_titre nowraponall center">';
 
  951  $arrayofoperators = array(
'0'=>
'', 
'='=>
'=', 
'<='=>
'<=', 
'>='=>
'>=');
 
  952  print $form->selectarray(
'search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0, 
'', 0, 0, 0, 
'', 
'maxwidth50imp');
 
  954  print $formother->select_month($search_dfmonth, 
'search_dfmonth', 1, 0);
 
  956  print $formother->selectyear($search_dfyear, 
'search_dfyear', 1, 20, 5, 0, 0, 
'');
 
  960if (!empty($arrayfields[
'status'][
'checked'])) {
 
  961  print 
'<td class="liste_titre right" colspan="4"></td>';
 
  966  print 
'<td class="liste_titre center">';
 
  967  $searchpicto = $form->showFilterButtons();
 
  973$totalarray = array();
 
  974$totalarray[
'nbfield'] = 0;
 
  978print 
'<tr class="liste_titre">';
 
  980  print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"], 
"", 
'', 
'', 
'', $sortfield, $sortorder, 
'center maxwidthsearch ');
 
  981  $totalarray[
'nbfield']++; 
 
  983if (!empty($arrayfields[
'c.ref'][
'checked'])) {
 
  984  print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"], 
"c.ref", 
"", $param, 
'', $sortfield, $sortorder);
 
  985  $totalarray[
'nbfield']++; 
 
  987if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
 
  988  print_liste_field_titre($arrayfields[
'c.ref_customer'][
'label'], $_SERVER[
"PHP_SELF"], 
"c.ref_customer", 
"", $param, 
'', $sortfield, $sortorder);
 
  989  $totalarray[
'nbfield']++; 
 
  991if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
 
  992  print_liste_field_titre($arrayfields[
'c.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"], 
"c.ref_supplier", 
"", $param, 
'', $sortfield, $sortorder);
 
  993  $totalarray[
'nbfield']++; 
 
  995if (!empty($arrayfields[
's.nom'][
'checked'])) {
 
  996  print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"], 
"s.nom", 
"", $param, 
'', $sortfield, $sortorder);
 
  997  $totalarray[
'nbfield']++; 
 
  999if (!empty($arrayfields[
's.email'][
'checked'])) {
 
 1000  print_liste_field_titre($arrayfields[
's.email'][
'label'], $_SERVER[
"PHP_SELF"], 
"s.email", 
"", $param, 
'', $sortfield, $sortorder);
 
 1001  $totalarray[
'nbfield']++; 
 
 1003if (!empty($arrayfields[
's.town'][
'checked'])) {
 
 1004  print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"], 
's.town', 
'', $param, 
'', $sortfield, $sortorder);
 
 1005  $totalarray[
'nbfield']++; 
 
 1007if (!empty($arrayfields[
's.zip'][
'checked'])) {
 
 1008  print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"], 
's.zip', 
'', $param, 
'', $sortfield, $sortorder);
 
 1009  $totalarray[
'nbfield']++; 
 
 1011if (!empty($arrayfields[
'state.nom'][
'checked'])) {
 
 1012  print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"], 
"state.nom", 
"", $param, 
'', $sortfield, $sortorder);
 
 1013  $totalarray[
'nbfield']++; 
 
 1015if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
 
 1016  print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"], 
"country.code_iso", 
"", $param, 
'', $sortfield, $sortorder, 
'center ');
 
 1017  $totalarray[
'nbfield']++; 
 
 1019if (!empty($arrayfields[
'typent.code'][
'checked'])) {
 
 1020  print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"], 
"typent.code", 
"", $param, 
'', $sortfield, $sortorder, 
'center ');
 
 1021  $totalarray[
'nbfield']++; 
 
 1023if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
 
 1024  print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"], 
"", 
"", $param, 
'', $sortfield, $sortorder);
 
 1025  $totalarray[
'nbfield']++; 
 
 1027if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
 
 1028  print_liste_field_titre($arrayfields[
'c.date_contrat'][
'label'], $_SERVER[
"PHP_SELF"], 
"c.date_contrat", 
"", $param, 
'', $sortfield, $sortorder, 
'center ');
 
 1029  $totalarray[
'nbfield']++; 
 
 1032include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
 
 1034$parameters = array(
'arrayfields'=>$arrayfields, 
'param'=>$param, 
'sortfield'=>$sortfield, 
'sortorder'=>$sortorder, 
'totalarray'=>&$totalarray);
 
 1035$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action); 
 
 1036print $hookmanager->resPrint;
 
 1037if (!empty($arrayfields[
'c.datec'][
'checked'])) {
 
 1038  print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"], 
"c.datec", 
"", $param, 
'', $sortfield, $sortorder, 
'center nowrap ');
 
 1039  $totalarray[
'nbfield']++; 
 
 1041if (!empty($arrayfields[
'c.tms'][
'checked'])) {
 
 1042  print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"], 
"c.tms", 
"", $param, 
'', $sortfield, $sortorder, 
'center nowrap ');
 
 1043  $totalarray[
'nbfield']++; 
 
 1045if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
 
 1046  print_liste_field_titre($arrayfields[
'lower_planned_end_date'][
'label'], $_SERVER[
"PHP_SELF"], 
"lower_planned_end_date", 
"", $param, 
'', $sortfield, $sortorder, 
'center ');
 
 1047  $totalarray[
'nbfield']++; 
 
 1049if (!empty($arrayfields[
'status'][
'checked'])) {
 
 1050  print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 
'class="nochangebackground"'), 
'', 
'', 
'', 
'', 
'width="16"');
 
 1051  $totalarray[
'nbfield']++; 
 
 1052  print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0, 
'class="nochangebackground"'), 
'', 
'', 
'', 
'', 
'width="16"');
 
 1053  $totalarray[
'nbfield']++; 
 
 1054  print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1, 
'class="nochangebackground"'), 
'', 
'', 
'', 
'', 
'width="16"');
 
 1055  $totalarray[
'nbfield']++; 
 
 1056  print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1, 
'class="nochangebackground"'), 
'', 
'', 
'', 
'', 
'width="16"');
 
 1057  $totalarray[
'nbfield']++; 
 
 1060  print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"], 
"", 
'', 
'', 
'', $sortfield, $sortorder, 
'center maxwidthsearch ');
 
 1061  $totalarray[
'nbfield']++; 
 
 1068$savnbfield = $totalarray[
'nbfield'];
 
 1069$totalarray = array();
 
 1070$totalarray[
'nbfield'] = 0;
 
 1071$typenArray = array();
 
 1072$cacheCountryIDCode = array();
 
 1073$imaxinloop = ($limit ? min($num, $limit) : $num);
 
 1074while ($i < $imaxinloop) {
 
 1075  $obj = $db->fetch_object($resql);
 
 1080  $contracttmp->ref = $obj->ref;
 
 1081  $contracttmp->id = $obj->rowid;
 
 1082  $contracttmp->ref_customer = $obj->ref_customer;
 
 1083  $contracttmp->ref_supplier = $obj->ref_supplier;
 
 1085  $contracttmp->nbofserviceswait = $obj->nb_initial;
 
 1086  $contracttmp->nbofservicesopened = $obj->nb_running;
 
 1087  $contracttmp->nbofservicesexpired = $obj->nb_expired;
 
 1088  $contracttmp->nbofservicesclosed = $obj->nb_closed;
 
 1090  $socstatic->id = $obj->socid;
 
 1091  $socstatic->name = $obj->name;
 
 1092  $socstatic->name_alias = $obj->name_alias;
 
 1093  $socstatic->email = $obj->email;
 
 1094  $socstatic->status = $obj->company_status;
 
 1095  $socstatic->logo = $obj->company_logo;
 
 1096  $socstatic->country_id = $obj->country_id;
 
 1097  $socstatic->country_code = 
'';
 
 1098  $socstatic->country = 
'';
 
 1100  if ($obj->country_id > 0) {
 
 1101    if (!isset($cacheCountryIDCode[$obj->country_id][
'code'])) {
 
 1102      $tmparray = 
getCountry($obj->country_id, 
'all');
 
 1103      $cacheCountryIDCode[$obj->country_id] = array(
'code'=> empty($tmparray[
'code']) ? 
'' : $tmparray[
'code'], 
'label' => empty($tmparray[
'label']) ? 
'' : $tmparray[
'label']);
 
 1105    $socstatic->country_code = $cacheCountryIDCode[$obj->country_id][
'code'];
 
 1106    $socstatic->country = $cacheCountryIDCode[$obj->country_id][
'label'];
 
 1109  if ($mode == 
'kanban') {
 
 1111      print 
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
 
 1112      print 
'<div class="box-flex-container kanban">';
 
 1115    $arraydata[
'thirdparty'] = $socstatic;
 
 1116    $arraydata[
'selected'] = in_array($obj->rowid, $arrayofselected);
 
 1117    $contracttmp->date_contrat = $obj->date_contrat;
 
 1118    print $contracttmp->getKanbanView(
'', $arraydata);
 
 1119    if ($i == ($imaxinloop - 1)) {
 
 1125    print 
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
 
 1128      print 
'<td class="nowrap center">';
 
 1129      if ($massactionbutton || $massaction) {   
 
 1131        if (in_array($obj->rowid, $arrayofselected)) {
 
 1134        print 
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ? 
' checked="checked"' : 
'').
'>';
 
 1138        $totalarray[
'nbfield']++;
 
 1142    if (!empty($arrayfields[
'c.ref'][
'checked'])) {
 
 1143      print 
'<td class="nowraponall">';
 
 1144      print $contracttmp->getNomUrl(1);
 
 1145      if ($obj->nb_late) {
 
 1148      if (!empty($obj->note_private) || !empty($obj->note_public)) {
 
 1149        print 
' <span class="note">';
 
 1150        print 
'<a href="'.DOL_URL_ROOT.
'/contrat/note.php?id='.$obj->rowid.
'&save_lastsearch_values=1">'.
img_picto($langs->trans(
"ViewPrivateNote"), 
'note').
'</a>';
 
 1156      $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
 
 1157      print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
 
 1162        $totalarray[
'nbfield']++;
 
 1167    if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
 
 1168      print 
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag(
dol_string_nohtmltag($contracttmp->getFormatedCustomerRef($obj->ref_customer))).
'">'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).
'</td>';
 
 1170        $totalarray[
'nbfield']++;
 
 1173    if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
 
 1174      print 
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>';
 
 1176    if (!empty($arrayfields[
's.nom'][
'checked'])) {
 
 1177      print 
'<td class="tdoverflowmax150">';
 
 1178      if ($obj->socid > 0) {
 
 1180        print $socstatic->getNomUrl(1, 
'');
 
 1185    if (!empty($arrayfields[
's.email'][
'checked'])) {
 
 1186      print 
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).
'">'.
dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).
'</td>';
 
 1189    if (!empty($arrayfields[
's.town'][
'checked'])) {
 
 1190      print 
'<td class="nocellnopadd">';
 
 1194        $totalarray[
'nbfield']++;
 
 1198    if (!empty($arrayfields[
's.zip'][
'checked'])) {
 
 1199      print 
'<td class="nocellnopadd">';
 
 1203        $totalarray[
'nbfield']++;
 
 1207    if (!empty($arrayfields[
'state.nom'][
'checked'])) {
 
 1208      print 
"<td>".$obj->state_name.
"</td>\n";
 
 1210        $totalarray[
'nbfield']++;
 
 1214    if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
 
 1215      print 
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($socstatic->country).
'">';
 
 1219        $totalarray[
'nbfield']++;
 
 1223    if (!empty($arrayfields[
'typent.code'][
'checked'])) {
 
 1224      print 
'<td class="center">';
 
 1225      if (count($typenArray) == 0) {
 
 1226        $typenArray = $formcompany->typent_array(1);
 
 1228      print $typenArray[$obj->typent_code];
 
 1231        $totalarray[
'nbfield']++;
 
 1234    if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
 
 1237      if ($obj->socid > 0) {
 
 1238        $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
 
 1239        if ($listsalesrepresentatives < 0) {
 
 1242        $nbofsalesrepresentative = count($listsalesrepresentatives);
 
 1243        if ($nbofsalesrepresentative > 6) {
 
 1245          print $nbofsalesrepresentative;
 
 1246        } elseif ($nbofsalesrepresentative > 0) {
 
 1247          $userstatic = 
new User($db);
 
 1249          foreach ($listsalesrepresentatives as $val) {
 
 1250            $userstatic->id = $val[
'id'];
 
 1251            $userstatic->lastname = $val[
'lastname'];
 
 1252            $userstatic->firstname = $val[
'firstname'];
 
 1253            $userstatic->email = $val[
'email'];
 
 1254            $userstatic->statut = $val[
'statut'];
 
 1255            $userstatic->entity = $val[
'entity'];
 
 1256            $userstatic->photo = $val[
'photo'];
 
 1257            $userstatic->login = $val[
'login'];
 
 1258            $userstatic->phone = $val[
'phone'];
 
 1259            $userstatic->job = $val[
'job'];
 
 1260            $userstatic->gender = $val[
'gender'];
 
 1263            print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, 
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
 
 1265            if ($j < $nbofsalesrepresentative) {
 
 1278    if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
 
 1279      print 
'<td class="center">'.dol_print_date($db->jdate($obj->date_contrat), 
'day', 
'tzserver').
'</td>';
 
 1282    include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
 
 1284    $parameters = array(
'arrayfields'=>$arrayfields, 
'obj'=>$obj, 
'i'=>$i, 
'totalarray'=>&$totalarray);
 
 1285    $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action); 
 
 1286    print $hookmanager->resPrint;
 
 1288    if (!empty($arrayfields[
'c.datec'][
'checked'])) {
 
 1289      print 
'<td class="center nowrap">';
 
 1290      print 
dol_print_date($db->jdate($obj->date_creation), 
'dayhour', 
'tzuser');
 
 1293        $totalarray[
'nbfield']++;
 
 1297    if (!empty($arrayfields[
'c.tms'][
'checked'])) {
 
 1298      print 
'<td class="center nowrap">';
 
 1299      print 
dol_print_date($db->jdate($obj->date_update), 
'dayhour', 
'tzuser');
 
 1302        $totalarray[
'nbfield']++;
 
 1306    if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
 
 1307      print 
'<td class="center nowrapforall">';
 
 1308      print 
dol_print_date($db->jdate($obj->lower_planned_end_date), 
'day', 
'tzuser');
 
 1311        $totalarray[
'nbfield']++;
 
 1315    if (!empty($arrayfields[
'status'][
'checked'])) {
 
 1316      print 
'<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial : 
'').
'</td>';
 
 1317      print 
'<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running : 
'').
'</td>';
 
 1318      print 
'<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired : 
'').
'</td>';
 
 1319      print 
'<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed : 
'').
'</td>';
 
 1321        $totalarray[
'nbfield']++;
 
 1322        $totalarray[
'nbfield']++;
 
 1323        $totalarray[
'nbfield']++;
 
 1324        $totalarray[
'nbfield']++;
 
 1329      print 
'<td class="nowrap center">';
 
 1330      if ($massactionbutton || $massaction) {   
 
 1332        if (in_array($obj->rowid, $arrayofselected)) {
 
 1335        print 
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ? 
' checked="checked"' : 
'').
'>';
 
 1339        $totalarray[
'nbfield']++;
 
 1351  foreach ($arrayfields as $key => $val) {
 
 1352    if (!empty($val[
'checked'])) {
 
 1356  print 
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
 
 1361$parameters = array(
'arrayfields'=>$arrayfields, 
'sql'=>$sql);
 
 1362$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action); 
 
 1363print $hookmanager->resPrint;
 
 1365print 
'</table>'.
"\n";
 
 1368print 
'</form>'.
"\n";
 
 1370$hidegeneratedfilelistifempty = 1;
 
 1371if ($massaction == 
'builddoc' || $action == 
'remove_file' || $show_files) {
 
 1372  $hidegeneratedfilelistifempty = 0;
 
 1376$urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
 
 1377$urlsource .= str_replace(
'&', 
'&', $param);
 
 1379$filedir = $diroutputmassaction;
 
 1380$genallowed = $permissiontoread;
 
 1381$delallowed = $permissiontoadd;
 
 1383print $formfile->showdocuments(
'massfilesarea_contract', 
'', $filedir, $urlsource, 0, $delallowed, 
'', 1, 1, 0, 48, 1, $param, $title, 
'', 
'', 
'', 
null, $hidegeneratedfilelistifempty);
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
 
Class to manage contracts.
 
Class to manage lines of contracts.
 
Class to manage third parties objects (customers, suppliers, prospects...)
 
Class to manage Dolibarr users.
 
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
 
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
 
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
 
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
 
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
 
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
 
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
 
dol_now($mode='auto')
Return date for now.
 
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
 
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
 
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
 
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
 
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.