diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 311531a52de..671bacee080 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2016 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -19,19 +19,20 @@ */ /** - * \file htdocs/admin/workflow.php - * \ingroup company - * \brief Workflows setup page + * \file htdocs/admin/workflow.php + * \ingroup company + * \brief Workflows setup page */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -// Load translation files required by the page -$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions")); - +// security check if (!$user->admin) accessforbidden(); +// Load translation files required by the page +$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions", "errors")); + $action = GETPOST('action', 'alpha'); @@ -39,157 +40,199 @@ $action = GETPOST('action', 'alpha'); * Actions */ -if (preg_match('/set(.*)/', $action, $reg)) -{ - if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) - { - dol_print_error($db); - } +if (preg_match('/set(.*)/', $action, $reg)) { + if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) { + dol_print_error($db); + } } -if (preg_match('/del(.*)/', $action, $reg)) -{ - if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) - { - dol_print_error($db); - } +if (preg_match('/del(.*)/', $action, $reg)) { + if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) { + dol_print_error($db); + } } +// List of workflow we can enable +clearstatcache(); + +$workflowcodes = array( + // Automatic creation + 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array( + 'family'=>'create', + 'position'=>10, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), + 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( + 'family'=>'create', + 'position'=>20, + 'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)), + 'picto'=>'bill' + ), + + 'separator1'=>array('family'=>'separator', 'position'=>25), + + // Automatic classification of proposal + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array( + 'family'=>'classify_proposal', + 'position'=>30, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'propal', + 'warning'=>'' + ), + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array( + 'family'=>'classify_proposal', + 'position'=>31, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->facture->enabled)), + 'picto'=>'propal', + 'warning'=>'' + ), + + // Automatic classification of order + 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array( + 'family'=>'classify_order', + 'position'=>40, + 'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array( + 'family'=>'classify_order', + 'position'=>41, + 'enabled'=>(!empty($conf->facture->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order', + 'warning'=>'' + ), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. + + 'separator2'=>array('family'=>'separator', 'position'=>50), + + // Automatic classification supplier proposal + 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array( + 'family'=>'classify_supplier_proposal', + 'position'=>60, + 'enabled'=>(!empty($conf->supplier_proposal->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 'picto'=>'propal', + 'warning'=>'' + ), + + // Automatic classification supplier order + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array( + 'family'=>'classify_supplier_order', + 'position'=>62, + 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), + 'picto'=>'order', + 'warning'=>'' + ), + + // Automatic classification reception + 'WORKFLOW_BILL_ON_RECEPTION'=>array( + 'family'=>'classify_reception', + 'position'=>64, + 'enabled'=>(!empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 'picto'=>'bill' + ), +); + +if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) { + foreach ($conf->modules_parts['workflow'] as $workflow) { + $workflowcodes = array_merge($workflowcodes, $workflow); + } +} + +// remove not available workflows (based on activated modules and global defined keys) +$workflowcodes = array_filter($workflowcodes, function ($var) { + return $var['enabled']; }); /* - * View + * View */ -llxHeader('', $langs->trans("WorkflowSetup"), ''); +llxHeader('', $langs->trans("WorkflowSetup"), "EN:Module_Workflow_En|FR:Module_Workflow|ES:Módulo_Workflow"); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("WorkflowSetup"), $linkback, 'title_setup'); -print ''.$langs->trans("WorkflowDesc").'
'; -print "
"; +print ''.$langs->trans("WorkflowDesc").''; +print '
'; +print '
'; -// List of workflow we can enable +// current module setup don't support any automatic workflow of this module +if (count($workflowcodes) < 1) { + print $langs->trans("ThereIsNoWorkflowToModify"); -clearstatcache(); - -$workflowcodes = array( - // Automatic creation - 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), - 'separator1'=>array('family'=>'separator', 'position'=>25), - // Automatic classification of proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal', 'warning'=>''), - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal', 'warning'=>''), - 'separator2'=>array('family'=>'separator', 'position'=>35), - // Automatic classification of order - 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order', 'warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. - 'separator3'=>array('family'=>'separator', 'position'=>50), - // Automatic classification supplier proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', 'picto'=>'propal', 'warning'=>''), - 'separator4'=>array('family'=>'separator', 'position'=>61), - // Automatic classification supplier order - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)', 'picto'=>'order', 'warning'=>''), - 'separator5'=>array('family'=>'separator', 'position'=>63), - // Automatic classification reception - 'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>64, 'enabled'=>'! empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', 'picto'=>'bill'), - 'separator6'=>array('family'=>'separator', 'position'=>90), - // Automatic classification of intervention - 'WORKFLOW_TICKET_CLOSE_INTERVENTION'=>array('family'=>'classify_intervention', 'position'=>100, 'enabled'=>'! empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)', 'picto'=>'intervention'), -); - -if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) -{ - foreach ($conf->modules_parts['workflow'] as $workflow) - { - $workflowcodes = array_merge($workflowcodes, $workflow); - } + llxFooter(); + $db->close(); + return; } // Sort on position $workflowcodes = dol_sort_array($workflowcodes, 'position'); -$nbqualified = 0; +print ''; + $oldfamily = ''; -print '
'."\n"; - -foreach ($workflowcodes as $key => $params) -{ - $picto = $params['picto']; - $enabled = $params['enabled']; - $family = $params['family']; - - if ($family == 'separator') - { - print '

'; - print ''."\n"; +foreach ($workflowcodes as $key => $params) { + if ($params['family'] == 'separator') { + print '
'; + print '
'; + print ''; continue; } - if (!verifCond($enabled)) continue; - - $nbqualified++; - - - if ($oldfamily != $family) - { - print ''."\n"; - print ' '; - print ' '; - print "\n"; - $oldfamily = $family; - } - print "\n"; - print "\n"; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + + $oldfamily = $params['family']; + } + + print ''; + print ''; + + print ''; + print ''; } -if ($nbqualified == 0) -{ - print '
'; - $reg = array(); - if ($family == 'create') { - print $langs->trans("AutomaticCreation"); - } elseif (preg_match('/classify_(.*)/', $family, $reg)) - { - print $langs->trans("AutomaticClassification"); - if ($reg[1] == 'proposal') print ' - '.$langs->trans('Proposal'); - if ($reg[1] == 'order') print ' - '.$langs->trans('Order'); - if ($reg[1] == 'supplier_proposal') print ' - '.$langs->trans('SupplierProposal'); - if ($reg[1] == 'supplier_order') print ' - '.$langs->trans('SupplierOrder'); - if ($reg[1] == 'reception') print ' - '.$langs->trans('Reception'); - if ($reg[1] == 'intervention') print ' - '.$langs->trans('Intervention'); + if ($oldfamily != $params['family']) { + if ($params['family'] == 'create') { + $header = $langs->trans("AutomaticCreation"); + } elseif (preg_match('/classify_(.*)/', $params['family'], $reg)) { + $header = $langs->trans("AutomaticClassification"); + if ($reg[1] == 'proposal') $header .= ' - '.$langs->trans('Proposal'); + if ($reg[1] == 'order') $header .= ' - '.$langs->trans('Order'); + if ($reg[1] == 'supplier_proposal') $header .= ' - '.$langs->trans('SupplierProposal'); + if ($reg[1] == 'supplier_order') $header .= ' - '.$langs->trans('SupplierOrder'); + if ($reg[1] == 'reception') $header .= ' - '.$langs->trans('Reception'); } else { - print $langs->trans("Description"); + $header = $langs->trans("Description"); } - print ''.$langs->trans("Status").'
".img_object('', $picto, 'class="paddingright"').$langs->trans('desc'.$key); - if (!empty($params['warning'])) - { - $langs->load("errors"); - print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); - } - print "'; - if (!empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff($key); - } else { - if (!empty($conf->global->$key)) - { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - } - print '
'.$header.''.$langs->trans("Status").'
'; + print img_object('', $params['picto']); + print ' '.$langs->trans('desc'.$key); + + if (!empty($params['warning'])) { + print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); + } + + print ''; + + if (!empty($conf->use_javascript_ajax)) { + print ajax_constantonoff($key); + } else { + if (!empty($conf->global->$key)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + } + + print '
'.$langs->trans("ThereIsNoWorkflowToModify"); -} print '
'; // End of page diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 5dade088fd0..58b8954762c 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1413,7 +1413,7 @@ class Setup extends DolibarrApi * @url GET conf/{constantname} * * @throws RestException 403 Forbidden - * @throws RestException 500 Error Bad or unknown value for constantname + * @throws RestException 404 Error Bad or unknown value for constantname */ public function getConf($constantname) { @@ -1425,7 +1425,7 @@ class Setup extends DolibarrApi } if (!preg_match('/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) { - throw new RestException(500, 'Error Bad or unknown value for constantname'); + throw new RestException(404, 'Error Bad or unknown value for constantname'); } if (preg_match('/(_pass|_pw|password|secret|_key|key$)/i', $constantname)) { throw new RestException(403, 'Forbidden'); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 602cde69163..555b5895fac 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -52,8 +53,7 @@ $bid = GETPOST('bid', 'int'); // Securite acces client $socid = GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) -{ +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -84,75 +84,65 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); print '
'; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -{ - // Search proposal - if (!empty($conf->propal->enabled) && $user->rights->propal->lire) - { - $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); - } - // Search customer order - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { - $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); - } - // Search supplier proposal - if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) - { - $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); - } - // Search supplier order - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) - { - $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); - } - // Search intervention - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) - { - $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); - } - // Search contract - if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) - { - $listofsearchfields['search_contract'] = array('text'=>'Contract'); - } +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo + // Search proposal + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { + $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); + } + // Search customer order + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { + $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); + } + // Search supplier proposal + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { + $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); + } + // Search supplier order + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { + $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); + } + // Search intervention + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { + $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); + } + // Search contract + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { + $listofsearchfields['search_contract'] = array('text'=>'Contract'); + } - if (count($listofsearchfields)) - { - print '
'; - print ''; - print '
'; - print ''; - $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
'; - print '
'; - print '
'; - print '
'; - } + if (count($listofsearchfields)) { + print '
'; + print ''; + print '
'; + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
'; + print '
'; + print '
'; + print '
'; + } } /* * Draft customer proposals */ -if (!empty($conf->propal->enabled) && $user->rights->propal->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -163,61 +153,48 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); - print '
'; - print ''; - print ''; - print ''; - - if ($num > 0) - { + if ($num > 0) { $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { + + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - print ''; - print ''; - print ''; + $companystatic->email = $obj->email; + $companystatic->code_compta = $obj->code_compta; + + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; $total += $obj->total_ht; } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - } else { - print ''; } - print "
'.$langs->trans("ProposalsDraft").' '.$num.'
'; $propalstatic->id = $obj->rowid; $propalstatic->ref = $obj->ref; - $propalstatic->ref_client = $obj->ref_client; - $propalstatic->total_ht = $obj->total_ht; - $propalstatic->total_tva = $obj->total_tva; - $propalstatic->total_ttc = $obj->total_ttc; - print $propalstatic->getNomUrl(1); - print ''; + $propalstatic->ref_client = $obj->ref_client; + $propalstatic->total_ht = $obj->total_ht; + $propalstatic->total_tva = $obj->total_tva; + $propalstatic->total_ttc = $obj->total_ttc; + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - $companystatic->code_compta = $obj->code_compta; - print $companystatic->getNomUrl(1, 'customer', 16); - print ''.price($obj->total_ht).'
'.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 16).''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoProposal").'

"; + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); $db->free($resql); } else { dol_print_error($db); @@ -225,101 +202,85 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) } - /* * Draft supplier proposals */ -if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) -{ - $langs->load("supplier_proposal"); +if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { + $langs->load("supplier_proposal"); - $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_statut = 0"; - $sql .= " AND p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= ", s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; - $resql = $db->query($sql); - if ($resql) - { - $total = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) { + $total = 0; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); - print '
'; - print ''; - print ''; - print ''; + if ($num > 0) { + $i = 0; - if ($num > 0) - { - $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($resql); + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); - print ''; - print ''; - print ''; - $i++; - $total += $obj->total_ht; - } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - } else { - print ''; - } - print "
'.$langs->trans("SupplierProposalsDraft").' '.$num.'
'; - $supplierproposalstatic->id = $obj->rowid; - $supplierproposalstatic->ref = $obj->ref; - $supplierproposalstatic->total_ht = $obj->total_ht; - $supplierproposalstatic->total_tva = $obj->total_tva; - $supplierproposalstatic->total_ttc = $obj->total_ttc; - print $supplierproposalstatic->getNomUrl(1); - print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; + $supplierproposalstatic->id = $obj->rowid; + $supplierproposalstatic->ref = $obj->ref; + $supplierproposalstatic->total_ht = $obj->total_ht; + $supplierproposalstatic->total_tva = $obj->total_tva; + $supplierproposalstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'supplier', 16); - print ''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoProposal").'

"; + $companystatic->email = $obj->email; - $db->free($resql); - } else { - dol_print_error($db); - } + print ''; + print ''.$supplierproposalstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'supplier', 16).''; + print ''.price($obj->total_ht).''; + print ''; + + $i++; + $total += $obj->total_ht; + } + } + + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); + } } /* * Draft customer orders */ -if (!empty($conf->commande->enabled) && $user->rights->commande->lire) -{ +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -330,64 +291,47 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($socid) $sql .= " AND c.fk_soc = ".$socid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("DraftOrders", "commande/list.php", "search_status=0", 2, $num); - print '
'; - print ''; - print ''; - print ''; - - if ($num > 0) - { + if ($num > 0) { $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { + + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - print ''; - print ''; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''; - } else { - print ''; - } + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->email = $obj->email; + $companystatic->entity = $obj->entity; + + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - } else { - print ''; } - print "
'.$langs->trans("DraftOrders").' '.$num.'
'; - $orderstatic->id = $obj->rowid; - $orderstatic->ref = $obj->ref; - $orderstatic->ref_client = $obj->ref_client; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; - print $orderstatic->getNomUrl(1); - print ''; + + $orderstatic->id = $obj->rowid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->email = $obj->email; - $companystatic->entity = $obj->entity; - print $companystatic->getNomUrl(1, 'customer', 16); - print ''.price($obj->total_ht).'
'.price($obj->total_ttc).'
'.$orderstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 16).''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoOrder").'
"; - print "

"; + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); $db->free($resql); } else { dol_print_error($db); @@ -398,108 +342,86 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) /* * Draft suppliers orders */ -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) -{ - $langs->load("orders"); +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { + $langs->load("orders"); - $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE cf.fk_soc = s.rowid"; - $sql .= " AND cf.fk_statut = 0"; - $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND cf.fk_soc = ".$socid; + $sql .= ", s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + $sql .= " AND cf.fk_statut = 0"; + $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND cf.fk_soc = ".$socid; - $resql = $db->query($sql); - if ($resql) - { - $total = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) { + $total = 0; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); - print '
'; - print ''; - print ''; - print ''; + if ($num > 0) { + $i = 0; - if ($num > 0) - { - $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($resql); - print ''; - print ''; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''; - } else { - print ''; - } - $i++; - $total += $obj->total_ttc; - } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - } else { - print ''; - } - print "
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'; - $supplierorderstatic->id = $obj->rowid; - $supplierorderstatic->ref = $obj->ref; - $supplierorderstatic->ref_supplier = $obj->ref_suppliert; - $supplierorderstatic->total_ht = $obj->total_ht; - $supplierorderstatic->total_tva = $obj->total_tva; - $supplierorderstatic->total_ttc = $obj->total_ttc; - print $supplierorderstatic->getNomUrl(1); - print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $supplierorderstatic->id = $obj->rowid; + $supplierorderstatic->ref = $obj->ref; + $supplierorderstatic->ref_supplier = $obj->ref_suppliert; + $supplierorderstatic->total_ht = $obj->total_ht; + $supplierorderstatic->total_tva = $obj->total_tva; + $supplierorderstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'supplier', 16); - print ''.price($obj->total_ht).'
'.price($obj->total_ttc).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoSupplierOrder").'
"; - print "

"; + $companystatic->email = $obj->email; - $db->free($resql); - } else { - dol_print_error($db); - } + print ''; + print ''.$supplierorderstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'supplier', 16).''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''; + + $i++; + $total += $obj->total_ttc; + } + } + + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); + } } - print '
'; - $max = 3; - /* * Last modified customers or prospects */ -if (!empty($conf->societe->enabled) && $user->rights->societe->lire) -{ +if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.code_compta"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 2, 3)"; @@ -510,63 +432,65 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $sql .= $db->plimit($max, 0); $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + if ($resql) { + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $header = "BoxTitleLastCustomersOrProspects"; + } + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $header = "BoxTitleLastModifiedProspects"; + } + else { + $header = "BoxTitleLastModifiedCustomers"; + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) - { - while ($i < $num) - { + $num = $db->num_rows($resql); + startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c", 1); + + if ($num) { + $i = 0; + + while ($i < $num && $i < $max) { $objp = $db->fetch_object($resql); + $companystatic->id = $objp->rowid; $companystatic->name = $objp->name; $companystatic->client = $objp->client; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->code_compta = $objp->code_compta; - $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; + print ''; print ''; - print '"; - print '"; + print ''; + print ''; print ''; + $i++; } - - $db->free($resql); - } else { - print ''; } - print "
'; - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects", $max); - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); - else print $langs->trans("BoxTitleLastModifiedCustomers", $max); - print ''.$langs->trans("FullList").'
'.$companystatic->getNomUrl(1, 'customer', 48).''; - print $companystatic->getLibCustProspStatut(); - print "'.dol_print_date($db->jdate($objp->tms), 'day')."'.$companystatic->getLibCustProspStatut().''.dol_print_date($db->jdate($objp->tms), 'day').'
'.$langs->trans("None").'
"; - print "

"; + + addSummaryTableLine(3, $num); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); } } -// Last suppliers -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) -{ + +/* + * Last suppliers + */ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; - $sql .= ", s.code_fournisseur"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.fournisseur = 1"; @@ -576,42 +500,38 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); + + if ($num) { + $i = 0; + while ($i < $num && $i < $max) { + $objp = $db->fetch_object($resql); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) - { - while ($i < $num && $i < $max) - { - $objp = $db->fetch_object($result); $companystatic->id = $objp->rowid; - $companystatic->name = $objp->name; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + $companystatic->name = $objp->name; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; - print ''; + $companystatic->email = $objp->email; + + print ''; print ''; print ''; print ''; $i++; } - } else { - print ''; } - print '
'.$langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)).''.$langs->trans("FullList").'
'.$companystatic->getNomUrl(1, 'supplier', 44).''.dol_print_date($db->jdate($objp->dm), 'day').'
'.$langs->trans("None").'
'; - print '

'; + + addSummaryTableLine(2, $num); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); } } @@ -619,8 +539,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU /* * Last actions */ -if ($user->rights->agenda->myactions->read) -{ +if ($user->rights->agenda->myactions->read) { show_array_last_actions_done($max); } @@ -628,8 +547,7 @@ if ($user->rights->agenda->myactions->read) /* * Actions to do */ -if ($user->rights->agenda->myactions->read) -{ +if ($user->rights->agenda->myactions->read) { show_array_actions_to_do(10); } @@ -637,15 +555,14 @@ if ($user->rights->agenda->myactions->read) /* * Latest contracts */ -if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT -{ +if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT $langs->load("contracts"); $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; - $sql .= ", s.code_client"; - $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; + $sql .= ", s.code_client"; + $sql .= ", s.entity"; + $sql .= ", s.email"; + $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; @@ -659,55 +576,53 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD $sql .= $db->plimit(5, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); + startSimpleTable($langs->trans("LastContracts", 5), "", "", 2); - if ($num > 0) - { - print '
'; - print ''; - print ''; + if ($num > 0) { $i = 0; - $staticcontrat = new Contrat($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; - print ''."\n"; - print "\n"; + $companystatic->email = $objp->email; + + print ''; + print ''; + print ''; + print ''; + print ''; $i++; } - print "
'.$langs->trans("LastContracts", 5).'
contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; - $companystatic->id = $objp->rowid; - $companystatic->name = $objp->name; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print '".$staticcontrat->LibStatut($obj->statut, 3)."
contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'.$companystatic->getNomUrl(1, 'customer', 44).''.$staticcontrat->LibStatut($obj->statut, 3).'
"; - print "

"; } + + addSummaryTableLine(2, $num); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } + /* * Opened proposals */ -if (!empty($conf->propal->enabled) && $user->rights->propal->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT s.nom as name, s.rowid, s.code_client"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; @@ -719,35 +634,39 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY p.rowid DESC"; - $result = $db->query($sql); - if ($result) - { + $resql = $db->query($sql); + if ($resql) { $total = 0; - $num = $db->num_rows($result); - $i = 0; - if ($num > 0) - { - print '
'; - print ''; - print ''; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($result); + if ($num > 0) { + $i = 0; + + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $propalstatic->id = $obj->propalid; + $propalstatic->ref = $obj->ref; + $propalstatic->ref_client = $obj->ref_client; + $propalstatic->total_ht = $obj->total_ht; + $propalstatic->total_tva = $obj->total_tva; + $propalstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print ''; // Ref print '"; - print ''; - print ''."\n"; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''; - } else { - print ''; - } - print ''."\n"; - print ''."\n"; + print ''; + print ''; + print ''; + print ''; + + print ''; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - print "
'.$langs->trans("ProposalsOpened").' '.$num.'
'; - - $propalstatic->id = $obj->propalid; - $propalstatic->ref = $obj->ref; - $propalstatic->ref_client = $obj->ref_client; - $propalstatic->total_ht = $obj->total_ht; - $propalstatic->total_tva = $obj->total_tva; - $propalstatic->total_ttc = $obj->total_ttc; - print ''; print '
'; print $propalstatic->getNomUrl(1); @@ -761,58 +680,39 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; - print "
'; - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''; - print dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ht).''.price($obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut, 3).'
'.$companystatic->getNomUrl(1, 'customer', 44).''.dol_print_date($db->jdate($obj->dp), 'day').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut, 3).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
"; - print "

"; } + + addSummaryTableLine(5, $num, $nbofloop, $total, "NoProposal", true); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } + /* * Opened Order */ -if (!empty($conf->commande->enabled) && $user->rights->commande->lire) -{ +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -823,35 +723,39 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY c.rowid DESC"; - $result = $db->query($sql); - if ($result) - { + $resql = $db->query($sql); + if ($resql) { $total = 0; - $num = $db->num_rows($result); - $i = 0; - if ($num > 0) - { - print '
'; - print ''; - print ''; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($result); + if ($num > 0) { + $i = 0; + + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $orderstatic->id = $obj->commandeid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print ''; // Ref print '"; - print ''; - print ''."\n"; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''; - } else { - print ''; - } - print ''."\n"; + print ''; + print ''; + print ''; + print ''; print ''."\n"; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - print "
'.$langs->trans("OrdersOpened").' '.$num.'
'; - - $orderstatic->id = $obj->commandeid; - $orderstatic->ref = $obj->ref; - $orderstatic->ref_client = $obj->ref_client; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; - print ''; print '
'; print $orderstatic->getNomUrl(1); @@ -865,49 +769,27 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir); print '
'; - print "
'; - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''; - print dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ht).''.price($obj->total_ttc).''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''.$companystatic->getNomUrl(1, 'customer', 44).''.dol_print_date($db->jdate($obj->dp), 'day').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
"; - print "

"; } + + addSummaryTableLine(5, $num, $nbofloop, $num, $total, "None", true); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } - - print '
'; $parameters = array('user' => $user); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index d33523863a3..bfb522b6e3a 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -95,6 +95,37 @@ class PaymentVarious extends CommonObject public $fk_user_modif; + /** + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + public $fields = array( + // TODO: fill this array + ); + // END MODULEBUILDER PROPERTIES + /** * Constructor * diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 9241608db8b..70963e29f6d 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -101,6 +101,37 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $typeid = ''; } +$search_all = GETPOSTISSET("search_all") ? trim(GETPOSTISSET("search_all", 'alpha')) : trim(GETPOST('sall')); + +/* +* TODO: fill array "$fields" in "/compta/bank/class/paymentvarious.class.php" and use +* +* +* $object = new PaymentVarious($db); +* +* $search = array(); +* foreach ($object->fields as $key => $val) +* { +* if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +* } + +* $fieldstosearchall = array(); +* foreach ($object->fields as $key => $val) +* { +* if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +* } +* +*/ + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'v.rowid'=>"Ref", + 'v.label'=>"Label", + 'v.datep'=>"DatePayment", + 'v.datev'=>"DateValue", + 'v.amount'=>$langs->trans("Debit").", ".$langs->trans("Credit"), +); + // Definition of fields for lists $arrayfields = array( 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), @@ -136,8 +167,6 @@ if (empty($reshook)) { * View */ -llxHeader(); - $form = new Form($db); if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); @@ -174,6 +203,7 @@ if ($filtre) { $filtre = str_replace(":", "=", $filtre); $sql .= " AND ".$filtre; } +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); $sql .= $db->order($sortfield, $sortorder); @@ -189,6 +219,19 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + + // Direct jump if only one record found + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) + { + $obj = $db->fetch_object($result); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id); + exit; + } + + // must be place behind the last "header(...)" call + llxHeader(); + $i = 0; $total = 0; @@ -226,6 +269,12 @@ if ($result) print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); + if ($search_all) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + } + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index bdd4eacc976..00b66ced374 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -119,6 +119,17 @@ if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFOR $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } +// Miscellaneous payments +if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) +{ + $arrayresult['searchintomiscpayments'] = array( + 'position'=>180, + 'img'=>'object_payment', + 'label'=>$langs->trans("SearchIntoMiscPayments", $search_boxvalue), + 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue), + 'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); +} + if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php new file mode 100644 index 00000000000..378aea61df5 --- /dev/null +++ b/htdocs/core/boxes/box_validated_projects.php @@ -0,0 +1,195 @@ + + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juan José Menent + * Copyright (C) 2020 Pierre Ardoin + * + * 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 . + */ + +/** + * \file htdocs/core/boxes/box_validated_projects.php + * \ingroup projet + * \brief Module to show validated projects whose tasks are assigned to the connected person, without any time entered by the connected person + */ +include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; + +/** + * Class to manage the box to show last projet + */ +class box_validated_projects extends ModeleBoxes +{ + public $boxcode="validated_project"; + public $boximg="object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs; + + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); + + $this->db = $db; + $this->boxlabel = "ValidatedProjects"; + + $this->hidden = ! ($user->rights->projet->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max=$max; + + $totalMnt = 0; + $totalnb = 0; + $totalnbTask=0; + + $textHead = $langs->trans("ValidatedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); + + $socid=0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId=''; + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + + $sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,"; + $sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; + $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")) AS 'taskNumber'"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; + $sql.= " WHERE p.fk_statut = 1"; // Only open projects + $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")"; + $sql.= " AND c.fk_socpeople = ".$user->id; + $sql.= " GROUP BY p.ref"; + $sql.= " ORDER BY p.dateo ASC"; + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => "Reference projet", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Client', + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Date debut de projet', + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Nombre de mes tâches sans temps saisi', + ); + $i++; + + while ($i < min($num+1, $max+1)) { + $objp = $this->db->fetch_object($result); + + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->Ref; + $projectstatic->customer = $objp->Client; + $projectstatic->startDate = $objp->startDate; + $projectstatic->taskNumber = $objp->taskNumber; + + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); + + $sql = 'SELECT rowid, nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client; + $resql = $this->db->query($sql); + if ($resql){ + $socstatic = new Societe($this->db); + $obj = $this->db->fetch_object($resql); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $obj->nom, + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj->rowid + ); + } + else { + dol_print_error($this->db); + } + + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->startDate, + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), + 'asis' => 1, + ); + $i++; + } + }else { + dol_print_error($this->db); + } + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1ed6056404e..f08516812be 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1218,13 +1218,13 @@ class ExtraFields } else { $labeltoshow = $obj->{$InfoFieldList[1]}; } - $labeltoshow = dol_trunc($labeltoshow, 45); + $labeltoshow = $labeltoshow; if ($value == $obj->rowid) { if (!$notrans) { foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); - $labeltoshow = dol_trunc($translabel, 18).' '; + $labeltoshow = $translabel.' '; } } $out .= ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index afa4c89460e..57941a4fb2d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8667,3 +8667,145 @@ function currentToken() { return $_SESSION['token']; } + +/** + * Start a table with headers and a optinal clickable number + * (don't forget to use "finishSimpleTable()" after the last table row) + * + * @see finishSimpleTable + * + * @param string $header The first left header of the table (automatic translated) + * @param string $link (optional) The link to a internal dolibarr page, when click on the number (without the first "/") + * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @param integer $emptyRows (optional) The count of empty rows after the first header + * @param integer $number (optional) The number that is shown right after the first header, when not set the link is shown on the right side of the header as "FullList" + * @return void + */ +function startSimpleTable($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) +{ + global $langs; + + print '
'; + print ''; + print ''; + + print $emptyRows < 1 ? ''; + + if ($number < 0 && !empty($link)) { + print ''; + } + + print ''; +} + +/** + * Add the correct HTML close tags for "startSimpleTable(...)" + * (use after the last table line) + * + * @see startSimpleTable + * + * @param bool $addLineBreak (optional) Add a extra line break after the complete table (\) + * + * @return void + */ +function finishSimpleTable($addLineBreak = false) +{ + print '
' : ''; + + print $langs->trans($header); + + // extra space between the first header and the number + if ($number > -1) { + print ' '; + } + + if (!empty($link)) { + if (!empty($arguments)) { + print ''; + } else { + print ''; + } + } + + if ($number > -1) { + print ''.$number.''; + } + + if (!empty($link)) { + print ''; + } + + print ''; + + if (!empty($arguments)) { + print ''; + } else { + print ''; + } + + print $langs->trans("FullList"); + print ''; + print '
'; + print '
'; + + if ($addLineBreak) { + print '
'; + } +} + +/** + * Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx") + * + * @param integer $tableColumnCount The complete count columns of the table + * @param integer $num The count of the rows of the table, when it is zero (0) the "$noneWord" is shown instead + * @param integer $nbofloop (optional) The maximum count of rows thaht the table show (when it is zero (0) no summary line will show, expect "$noneWord" when $num === 0) + * @param integer $total (optional) The total value thaht is shown after when the table has minimum of one entire + * @param string $noneWord (optional) The word that is shown when the table has no entires ($num === 0) + * @param boolean $extraRightColumn (optional) Add a addtional column after the summary word and total number + * @return void + */ +function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false) +{ + global $langs; + + if ($num === 0) { + print ''; + print ''.$langs->trans($noneWord).''; + print ''; + return; + } + + if ($nbofloop === 0) + { + // don't show a summary line + return; + } + + if ($num === 0) { + $colspan = $tableColumnCount; + } + elseif ($num > $nbofloop) { + $colspan = $tableColumnCount; + } else { + $colspan = $tableColumnCount - 1; + } + + if ($extraRightColumn) { + $colspan--; + } + + print ''; + + if ($nbofloop > 0 && $num > $nbofloop) { + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).''; + } else { + print ' '.$langs->trans("Total").''; + print ''.price($total).''; + } + + if ($extraRightColumn) { + print ''; + } + + print ''; +} diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 77d339da035..ad77f85dfb5 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -144,6 +144,8 @@ class modProjet extends DolibarrModules $r++; $this->boxes[$r][1] = "box_task.php"; $r++; + $this->boxes[$r][1] = "box_validated_projects.php"; + $r++; // Permissions $this->rights = array(); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 9e666033d83..be53ebefaeb 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1879,9 +1879,9 @@ class EmailCollector extends CommonObject $tickettocreate->subject = $subject; $tickettocreate->message = $description; - $tickettocreate->type_code = 0; - $tickettocreate->category_code = null; - $tickettocreate->severity_code = null; + $tickettocreate->type_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_TYPE_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_type', 'use_default', 'code', 1)); + $tickettocreate->category_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_CATEGORY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_category', 'use_default', 'code', 1)); + $tickettocreate->severity_code = (!empty($conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE) ? $conf->global->MAIN_EMAILCOLLECTOR_TICKET_SEVERITY_CODE : dol_getIdFromCode($this->db, 1, 'c_ticket_severity', 'use_default', 'code', 1)); $tickettocreate->origin_email = $from; $tickettocreate->fk_user_create = $user->id; $tickettocreate->datec = $date; diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index ab89bc10c4b..14db79809bc 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -104,3 +104,4 @@ BoxTitleLastCustomerShipments=Latest %s customer shipments NoRecordedShipments=No recorded customer shipment # Pages AccountancyHome=Accountancy +ValidatedProjects=Validated projects diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 304c75601f1..a2c314bc7cc 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1011,6 +1011,7 @@ SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports SearchIntoLeaves=Leave SearchIntoTickets=Tickets +SearchIntoMiscPayments=Miscellaneous payments CommentLink=Comments NbComments=Number of comments CommentPage=Comments space @@ -1086,4 +1087,4 @@ MODIFYInDolibarr=Record %s modified DELETEInDolibarr=Record %s deleted VALIDATEInDolibarr=Record %s validated APPROVEDInDolibarr=Record %s approved -DefaultMailModel=Default Mail Model \ No newline at end of file +DefaultMailModel=Default Mail Model