--- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_card.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -49,2 +47,0 @@ -$notab = GETPOST('notab', 'int'); -$type = GETPOST('type', 'alpha'); @@ -56,7 +53,2 @@ -$socid = GETPOST('socid', 'int'); -if (!empty($user->socid)) { - $socid = $user->socid; -} -if ($socid < 0) { - $socid = 0; -} +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; @@ -65 +57 @@ -$fieldvalue = ($id > 0 ? $id : $ref); +$fieldvalue = (!empty($id) ? $id : $ref); @@ -67,3 +59 @@ - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('productstatscard', 'globalcard')); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -73,11 +63 @@ -if (empty($search_year)) { - $search_year = $currentyear; -} -$moreforfilter = ""; - -$object = new Product($db); -if ($id > 0 || !empty($ref)) { - $result = $object->fetch($id, $ref); -} - -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +if (empty($search_year)) $search_year = $currentyear; @@ -99,31 +79,36 @@ - -if (!($id > 0) && empty($ref) || $notab) { - $notab = 1; - - llxHeader("", $langs->trans("ProductStatistics")); - - $type = GETPOST('type', 'int'); - - $helpurl = ''; - if ($type == '0') { - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - //$title=$langs->trans("StatisticsOfProducts"); - $title = $langs->trans("Statistics"); - } elseif ($type == '1') { - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - //$title=$langs->trans("StatisticsOfServices"); - $title = $langs->trans("Statistics"); - } else { - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - //$title=$langs->trans("StatisticsOfProductsOrServices"); - $title = $langs->trans("Statistics"); - } - - $picto = 'product'; - if ($type == 1) { - $picto = 'service'; - } - - print load_fiche_titre($title, $mesg, $picto); -} else { - $result = $object->fetch($id, $ref); +$object = new Product($db); + +if (!$id && empty($ref)) +{ + llxHeader("", $langs->trans("ProductStatistics")); + + $type = GETPOST('type', 'int'); + + $helpurl = ''; + if ($type == '0') + { + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + //$title=$langs->trans("StatisticsOfProducts"); + $title = $langs->trans("Statistics"); + } + elseif ($type == '1') + { + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfServices"); + $title = $langs->trans("Statistics"); + } + else + { + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfProductsOrServices"); + $title = $langs->trans("Statistics"); + } + + $picto = 'product'; + if ($type == 1) $picto = 'service'; + + print load_fiche_titre($title, $mesg, $picto); +} +else +{ + $result = $object->fetch($id, $ref); @@ -134 +119,2 @@ - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) + { @@ -138 +124,2 @@ - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) + { @@ -147 +134,2 @@ -if ($result && ($id > 0 || !empty($ref)) && empty($notab)) { +if ($result && (!empty($id) || !empty($ref))) +{ @@ -152,16 +140,17 @@ - print dol_get_fiche_head($head, 'stats', $titre, -1, $picto); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1); - - print dol_get_fiche_end(); -} -if ((!($id > 0) && empty($ref)) || $notab) { - $h = 0; - $head = array(); - - $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.((int) $type) : ''); - $head[$h][1] = $langs->trans("Chart"); - $head[$h][2] = 'chart'; - $h++; + dol_fiche_head($head, 'stats', $titre, -1, $picto); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1); + + dol_fiche_end(); +} +if (empty($id) & empty($ref)) +{ + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.$type : ''); + $head[$h][1] = $langs->trans("Chart"); + $head[$h][2] = 'chart'; + $h++; @@ -170,29 +159,25 @@ - if ((string) $type == '0') { - $title = $langs->trans("ListProductByPopularity"); - } - if ((string) $type == '1') { - $title = $langs->trans("ListServiceByPopularity"); - } - - - $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.((int) $type) : ''); - $head[$h][1] = $langs->trans("ProductsServicesPerPopularity"); - if ((string) $type == '0') { - $head[$h][1] = $langs->trans("ProductsPerPopularity"); - } - if ((string) $type == '1') { - $head[$h][1] = $langs->trans("ServicesPerPopularity"); - } - $head[$h][2] = 'popularity'; - $h++; - - print dol_get_fiche_head($head, 'chart', '', -1); -} - - -if ($result || !($id > 0)) { - print '
'; - print ''; - if (empty($id) || $notab) { - print ''; - } + if ((string) $type == '1') { + $title = $langs->trans("ListServiceByPopularity"); + } + if ((string) $type == '0') { + $title = $langs->trans("ListProductByPopularity"); + } + + $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.$type : ''); + $head[$h][1] = $langs->trans("PopuProp"); + $head[$h][2] = 'popularityprop'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/product/popucom.php'.($type != '' ? '?type='.$type : ''); + $head[$h][1] = $langs->trans("PopuCom"); + $head[$h][2] = 'popularitycommande'; + $h++; + + dol_fiche_head($head, 'chart', $langs->trans("Statistics"), -1); +} + + +if ($result || empty($id)) +{ + print ''; + print ''; @@ -201,5 +186,6 @@ - print ''.$langs->trans("Filter").''; - - if (!($id > 0) || $notab) { - // Type - print ''.$langs->trans("Type").''; + print ''.$langs->trans("Filter").''; + + if (empty($id)) + { + // Type + print ''.$langs->trans("ProductsAndServices").''; @@ -207 +193 @@ - print $form->selectarray('type', $array, $type, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + print $form->selectarray('type', $array, $type); @@ -210,6 +195,0 @@ - // Product - print ''.$langs->trans("ProductOrService").''; - print img_picto('', 'product', 'class="pictofixedwidth"'); - print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', ($conf->dol_optimize_smallscreen ? 1 : 0), array(), 0, '1', 0, 'widthcentpercentminusx maxwidth400'); - print ''; - @@ -217,6 +197,8 @@ - if (isModEnabled('categorie')) { - print ''.$langs->trans("Categories").''; - $moreforfilter .= img_picto($langs->trans("Categories"), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, 1, 'widthcentpercentminusx maxwidth400'); - print $moreforfilter; - print ''; + if ($conf->categorie->enabled) + { + print ''.$langs->trans("Categories").''; + //$moreforfilter.='
'; + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); + //$moreforfilter.='
'; + print $moreforfilter; + print ''; @@ -224,2 +205,0 @@ - } else { - print ''; @@ -229 +209 @@ - print ''.$langs->trans("Year").''; + print ''.$langs->trans("Year").''; @@ -231,9 +211,6 @@ - for ($year = $currentyear - 25; $year < $currentyear; $year++) { - $arrayyears[$year] = $year; - } - if (!in_array($year, $arrayyears)) { - $arrayyears[$year] = $year; - } - if (!in_array($currentyear, $arrayyears)) { - $arrayyears[$currentyear] = $currentyear; - } + for ($year = $currentyear - 10; $year < $currentyear + 10; $year++) + { + $arrayyears[$year] = $year; + } + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -241 +218 @@ - print $form->selectarray('search_year', $arrayyears, $search_year, 1, 0, 0, '', 0, 0, 0, '', 'width75'); + print $form->selectarray('search_year', $arrayyears, $search_year, 0); @@ -243,7 +219,0 @@ - - // thirdparty - print ''.$langs->trans("ThirdParty").''; - print img_picto('', 'company', 'class="pictofixedwidth"'); - print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth400'); - print ''; - @@ -251,2 +221,2 @@ - print '
'; - print '

'; + print '
'; + print ''; @@ -257,6 +226,0 @@ - $param = ''; - $param .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : '&id='.$object->id).(($type != '' && $type != '-1') ? '&type='.((int) $type) : '').'&search_year='.((int) $search_year).($notab ? '¬ab='.$notab : ''); - if ($socid > 0) { - $param .= '&socid='.((int) $socid); - } - @@ -264,32 +228,12 @@ - - if (!empty($conf->dol_use_jmobile)) { - print "\n".'
'."\n"; - } - - if ($mode != 'byunit') { - print ''; - } else { - print ''; - } - if ($type == '0') { - print $langs->trans("StatsByNumberOfUnitsProducts"); - } elseif ($type == '1') { - print $langs->trans("StatsByNumberOfUnitsServices"); - } else { - print $langs->trans("StatsByNumberOfUnits"); - } - if ($mode != 'byunit') { - print ''; - } else { - print ''; - } - - if (!empty($conf->dol_use_jmobile)) { - print '
'."\n".'
'."\n"; - } - - if ($mode != 'bynumber') { - print ''; - } else { - print ''; - } + if (!empty($conf->dol_use_jmobile)) print "\n".''; - } else { - print '
'; - } + if ($mode == 'byunit') print ''; + + if (!empty($conf->dol_use_jmobile)) print '
'; + else print '
'; @@ -333,5 +247,10 @@ - // Generation of graphs - $dir = (!empty($conf->product->multidir_temp[$conf->entity]) ? $conf->product->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); - if ($object->id > 0) { // We are on statistics for a dedicated product - if (!file_exists($dir.'/'.$object->id)) { - if (dol_mkdir($dir.'/'.$object->id) < 0) { + //print ''; + + // Generation des graphs + $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); + if ($object->id > 0) // We are on statistics for a dedicated product + { + if (!file_exists($dir.'/'.$object->id)) + { + if (dol_mkdir($dir.'/'.$object->id) < 0) + { @@ -344,3 +263 @@ - $arrayforlabel = array('byunit' => 'NumberOfUnits', 'bynumber' => 'NumberOf', 'byamount' => 'AmountIn'); - - if (isModEnabled('propal')) { + if ($conf->propal->enabled) { @@ -348,6 +265,5 @@ - 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Proposals"))); - } - - if (isModEnabled('supplier_proposal')) { - $langs->load("supplier_proposal"); + 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals"))); + } + + if ($conf->supplier_proposal->enabled) { @@ -355,5 +271,5 @@ - 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SupplierProposals"))); - } - - if (isModEnabled('order')) { + 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals"))); + } + + if ($conf->order->enabled) { @@ -361,5 +277,5 @@ - 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Orders"))); - } - - if (isModEnabled('supplier_order')) { + 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders"))); + } + + if ($conf->supplier_order->enabled) { @@ -367,5 +283,5 @@ - 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SuppliersOrders"))); - } - - if (isModEnabled('facture')) { + 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders"))); + } + + if ($conf->facture->enabled) { @@ -373,5 +289,5 @@ - 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Invoices"))); - } - - if (isModEnabled('supplier_invoice')) { + 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))); + } + + if ($conf->supplier_invoice->enabled) { @@ -379,5 +295,5 @@ - 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("SupplierInvoices"))); - } - - if (isModEnabled('contrat')) { + 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))); + } + + if ($conf->contrat->enabled) { @@ -385,5 +301,5 @@ - 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode], $langs->transnoentitiesnoconv("Contracts"))); - } - - if (isModEnabled('mrp') && $mode != 'byamount') { + 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts"))); + } + + if ($conf->mrp->enabled) { @@ -391,2 +307,2 @@ - 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year > 0 ? '_year'.$search_year : '').'.png', - 'label' => $langs->transnoentitiesnoconv($arrayforlabel[$mode]."Mos")); + 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos"))); @@ -397 +313,2 @@ - if (!$error && count($graphfiles) > 0) { + if (!$error && count($graphfiles) > 0) + { @@ -399,4 +316,11 @@ - if (!$mesg) { - foreach ($graphfiles as $key => $val) { - if (!$graphfiles[$key]['file']) { - continue; + if (!$mesg) + { + foreach ($graphfiles as $key => $val) + { + if (!$graphfiles[$key]['file']) continue; + + $graph_data = array(); + + if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) + { + // TODO Load cachefile $graphfiles[$key]['file'] @@ -404,41 +328,23 @@ - - $graph_data = array(); - - if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) { - // TODO Load cachefile $graphfiles[$key]['file'] - } else { - $morefilters = ''; - if ($search_categ > 0) { - $categ = new Categorie($db); - $categ->fetch($search_categ); - $listofprodids = $categ->getObjectsInCateg('product', 1); - $morefilters = ' AND d.fk_product IN ('.$db->sanitize((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; - } - if ($search_categ == -2) { - $morefilters = ' AND NOT EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE d.fk_product = cp.fk_product)'; - } - - if ($key == 'propal') { - $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } - if ($key == 'orders') { - $graph_data = $object->get_nb_order($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } - if ($key == 'invoices') { - $graph_data = $object->get_nb_vente($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } - if ($key == 'proposalssuppliers') { - $graph_data = $object->get_nb_propalsupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } - if ($key == 'invoicessuppliers') { - $graph_data = $object->get_nb_achat($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } - if ($key == 'orderssuppliers') { - $graph_data = $object->get_nb_ordersupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } - if ($key == 'contracts') { - $graph_data = $object->get_nb_contract($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } - if ($key == 'mrp') { - $graph_data = $object->get_nb_mos($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); - } + else + { + $morefilters = ''; + if ($search_categ > 0) + { + $categ = new Categorie($db); + $categ->fetch($search_categ); + $listofprodids = $categ->getObjectsInCateg('product', 1); + $morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; + } + if ($search_categ == -2) + { + $morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; + } + + if ($key == 'propal') $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'orders') $graph_data = $object->get_nb_order($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'proposalssuppliers') $graph_data = $object->get_nb_propalsupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'contracts') $graph_data = $object->get_nb_contract($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'mrp') $graph_data = $object->get_nb_mos($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); @@ -449 +355,2 @@ - if (is_array($graph_data)) { + if (is_array($graph_data)) + { @@ -461 +368 @@ - $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.((int) $object->entity).'&file='.urlencode($graphfiles[$key]['file']).($notab ? '¬ab='.$notab : ''); + $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); @@ -466 +373,3 @@ - } else { + } + else + { @@ -477,30 +386,17 @@ - if (count($graphfiles) > 0) { - foreach ($graphfiles as $key => $val) { - if (!$graphfiles[$key]['file']) { - continue; - } - - if ($graphfiles == 'propal' && !$user->hasRight('propal', 'lire')) { - continue; - } - if ($graphfiles == 'order' && !$user->hasRight('commande', 'lire')) { - continue; - } - if ($graphfiles == 'invoices' && !$user->hasRight('facture', 'lire')) { - continue; - } - if ($graphfiles == 'proposals_suppliers' && !$user->hasRight('supplier_proposal', 'lire')) { - continue; - } - if ($graphfiles == 'invoices_suppliers' && !$user->hasRight('fournisseur', 'facture', 'lire')) { - continue; - } - if ($graphfiles == 'orders_suppliers' && !$user->hasRight('fournisseur', 'commande', 'lire')) { - continue; - } - if ($graphfiles == 'mrp' && !$user->hasRight('mrp', 'read')) { - continue; - } - - - if ($i % 2 == 0) { + if (count($graphfiles) > 0) + { + foreach ($graphfiles as $key => $val) + { + if (!$graphfiles[$key]['file']) continue; + + if ($graphfiles == 'propal' && !$user->rights->propale->lire) continue; + if ($graphfiles == 'order' && !$user->rights->commande->lire) continue; + if ($graphfiles == 'invoices' && !$user->rights->facture->lire) continue; + if ($graphfiles == 'proposals_suppliers' && !$user->rights->supplier_proposal->lire) continue; + if ($graphfiles == 'invoices_suppliers' && !$user->rights->fournisseur->facture->lire) continue; + if ($graphfiles == 'orders_suppliers' && !$user->rights->fournisseur->commande->lire) continue; + if ($graphfiles == 'mrp' && empty($user->rights->mrp->mo->read)) continue; + + + if ($i % 2 == 0) + { @@ -508,2 +404,4 @@ - } else { - print "\n".'
'."\n"; + } + else + { + print "\n".'
'."\n"; @@ -513,13 +411,10 @@ - if ($graphfiles[$key]['output'] && !$px->isGraphKo()) { - if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) { - $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); - } else { - $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); - } - } else { - $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); - } - $linktoregenerate = ' 0 ? '&search_categ='.((int) $search_categ) : '').'">'; - $linktoregenerate .= img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh'); - $linktoregenerate .= ''; - + if ($graphfiles[$key]['output'] && !$px->isGraphKo()) + { + if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); + else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); + } + else + { + $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); + } + $linktoregenerate = 'id).((string) $type != '' ? '&type='.$type : '').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; @@ -528 +422,0 @@ - print '
'; @@ -537 +431 @@ - print '
'; + if ($num < $limit) print ''; + else print ''; + print ''; + print ''; + print ''; + print ''; + print "
'; + print '
'; @@ -541,3 +435,3 @@ - print ''; - - if ($i % 2 == 0) { + + if ($i % 2 == 0) + { @@ -545,2 +439,4 @@ - } else { - print "\n".''; + } + else + { + print "\n".''; @@ -554,3 +450,4 @@ - if ($i % 2 == 1) { - print "\n".'
'."\n"; - print "\n".'
'; + if ($i % 2 == 1) + { + print "\n".'
'."\n"; + print "\n".'
'; @@ -561,2 +458,3 @@ -if (!($id > 0)) { - print dol_get_fiche_end(); +if (!$id) +{ + dol_fiche_end(); --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_commande.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_commande.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -44,3 +43,2 @@ -if (!empty($user->socid)) { - $socid = $user->socid; -} +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -50,0 +49,2 @@ +$mesg = ''; + @@ -52,3 +52,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -56,3 +56 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -62,7 +60,3 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "c.date_commande"; -} -$search_month = GETPOST('search_month', 'int'); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "c.date_commande"; +$search_month = GETPOST('search_month', 'alpha'); @@ -76,3 +69,0 @@ -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); - - @@ -89 +80,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -97,3 +89 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -103 +93,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -107 +98 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -110,20 +101,16 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - print '
'; - - print '
'; - print ''; - - $nboflines = show_stats_for_company($product, $socid); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); @@ -133,7 +120,8 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); - - - if ($user->hasRight('commande', 'lire')) { + print ''; + print '
'; + + dol_fiche_end(); + + + if ($user->rights->commande->lire) + { @@ -142,5 +130,2 @@ - $sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty,"; - $sql .= " c.date_livraison as delivery_date"; - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", sc.fk_soc, sc.fk_user "; - } + $sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -150,3 +135 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -156,13 +139,7 @@ - $sql .= " AND d.fk_product = ".((int) $product->id); - if (!empty($search_month)) { - $sql .= ' AND MONTH(c.date_commande) IN ('.$db->sanitize($search_month).')'; - } - if (!empty($search_year)) { - $sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')'; - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND c.fk_soc = ".((int) $socid); - } + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; @@ -171,12 +148,13 @@ - //Calcul total qty and amount for global if full scan list - $total_ht = 0; - $total_qty = 0; - - // Count total nb of records - $totalofrecords = ''; - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $totalofrecords = $db->num_rows($result); - } - - $sql .= $db->plimit($limit + 1, $offset); + //Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); @@ -185 +163,2 @@ - if ($result) { + if ($result) + { @@ -188,30 +167,18 @@ - $option = '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } - - print ''."\n"; - print ''; - if (!empty($sortfield)) { - print ''; - } - if (!empty($sortorder)) { - print ''; - } - - print_barre_liste($langs->trans("CustomersOrders"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } - - print '
'; - print '
'; - print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + + print_barre_liste($langs->trans("CustomersOrders"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) $option .= '&page='.urlencode($page); + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; @@ -222,0 +190 @@ + print '
'; @@ -225 +192,0 @@ - print '
'; @@ -228 +195 @@ - print '
'; + print '
'; @@ -234,5 +201,4 @@ - print_liste_field_titre("OrderDate", $_SERVER["PHP_SELF"], "c.date_commande", "", $option, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateDeliveryPlanned', $_SERVER['PHP_SELF'], 'c.date_livraison', '', $option, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "c.total_ht", "", $option, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("OrderDate", $_SERVER["PHP_SELF"], "c.date_commande", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "c.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); @@ -241,2 +207,4 @@ - if ($num > 0) { - while ($i < min($num, $limit)) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { @@ -254,5 +222,5 @@ - print '
\n"; - print ''; - print "\n"; + print '\n"; + print ''; + print "\n"; @@ -261,4 +228,0 @@ - // delivery planned date - print ''; @@ -266 +230 @@ - print '\n"; + print '\n"; @@ -272,16 +236,11 @@ - print ''; - if ($num < $limit) { - print ''; - } else { - print ''; - } - print ''; - // delivery planned date - print ''; - print ''; - print ''; - print ''; - print "
'; - print $orderstatic->getNomUrl(1); - print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; + print $orderstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; - print dol_print_date($db->jdate($objp->delivery_date), 'dayhour'); - print ''.price($objp->total_ht)."'.price($objp->total_ht)."
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.price($total_ht).'
"; - print "
"; - print ''; - } else { + print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.price($total_ht).'
"; + print ""; + print ''; + } else { --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_commande_fournisseur.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_commande_fournisseur.php @@ -42 +42 @@ -if (!empty($user->socid)) { +if (!empty($user->socid)) @@ -44 +44 @@ -} +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -47 +47 @@ -$hookmanager->initHooks(array('productstatssupplierorder')); +$hookmanager->initHooks(array('productstatssupplyorder')); @@ -52,3 +52,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -56,3 +56 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -62 +60 @@ -if (!$sortorder) { +if (!$sortorder) @@ -64,2 +62 @@ -} -if (!$sortfield) { +if (!$sortfield) @@ -67,2 +64 @@ -} -$search_month = GETPOST('search_month', 'int'); +$search_month = GETPOST('search_month', 'alpha'); @@ -76,2 +71,0 @@ -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); - @@ -97 +91 @@ - if ($reshook < 0) { + if ($reshook < 0) @@ -99 +92,0 @@ - } @@ -103 +96,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -107 +101 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -110,4 +104,2 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -117,4 +109,2 @@ - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; @@ -124,6 +114,6 @@ - print '
'; - - print '
'; - print ''; - - $nboflines = show_stats_for_company($product, $socid); + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); @@ -133,7 +123,8 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); - - - if ($user->hasRight('fournisseur', 'commande', 'lire')) { + print ''; + print '
'; + + dol_fiche_end(); + + + if ($user->rights->fournisseur->commande->lire) + { @@ -142,3 +133,2 @@ - $sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty,"; - $sql .= " c.date_livraison as delivery_date"; - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + $sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty"; + if (!$user->rights->societe->client->voir && !$socid) @@ -146 +135,0 @@ - } @@ -150 +139 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) @@ -152 +140,0 @@ - } @@ -154 +142 @@ - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND c.entity = ".$conf->entity; @@ -156,13 +144,9 @@ - $sql .= " AND d.fk_product = ".((int) $product->id); - if (!empty($search_month)) { - $sql .= ' AND MONTH(c.date_commande) IN ('.$db->sanitize($search_month).')'; - } - if (!empty($search_year)) { - $sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')'; - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND c.fk_soc = ".((int) $socid); - } + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) + $sql .= " AND c.fk_soc = ".$socid; @@ -177 +161,2 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { @@ -188,11 +173,4 @@ - $option = '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); @@ -201,2 +179 @@ - print ''; - if (!empty($sortfield)) { + if (!empty($sortfield)) @@ -204,2 +181 @@ - } - if (!empty($sortorder)) { + if (!empty($sortorder)) @@ -207 +182,0 @@ - } @@ -211,3 +186 @@ - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } + if (!empty($page)) $option .= '&page='.urlencode($page); @@ -216 +189 @@ - print '
'; + print '
'; @@ -228,2 +201,2 @@ - print '
'; - print '
'; + print '
'; + print '
'; @@ -235 +207,0 @@ - print_liste_field_titre('DateDeliveryPlanned', $_SERVER['PHP_SELF'], 'c.date_livraison', '', $option, 'align="center"', $sortfield, $sortorder); @@ -241,2 +213,4 @@ - if ($num > 0) { - while ($i < min($num, $limit)) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { @@ -261,4 +234,0 @@ - // delivery planned date - print ''; @@ -273,5 +243,2 @@ - if ($num < $limit) { - print ''; - } else { - print ''; - } + if ($num < $limit) print ''; + else print ''; @@ -279,2 +245,0 @@ - // delivery planned date - print ''; --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_contrat.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_contrat.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -41,3 +40,2 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -47,0 +46,2 @@ +$mesg = ''; + @@ -49,3 +49,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -53,3 +53 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -59,8 +57,2 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "c.date_contrat"; -} - -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "c.date_contrat"; @@ -78 +70,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -86,3 +79 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -92 +83,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -96 +88 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -99,20 +91,16 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - print '
'; - - print '
'; - print '
'; - print dol_print_date($db->jdate($objp->delivery_date), 'dayhour'); - print ''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'; - - $nboflines = show_stats_for_company($product, $socid); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); @@ -122,4 +110,4 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); + print ''; + print '
'; + + dol_fiche_end(); @@ -131,4 +119,4 @@ - $sql .= " sum(".$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; - $sql .= " sum(".$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", 1, 0).") as nb_running,"; - $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_late,'; - $sql .= " sum(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; + $sql .= ' sum('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; + $sql .= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", 1, 0).") as nb_running,"; + $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_late,'; + $sql .= ' sum('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; @@ -138,3 +126 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -146,7 +132,3 @@ - $sql .= " AND cd.fk_product = ".((int) $product->id); - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND s.rowid = ".((int) $socid); - } + $sql .= " AND cd.fk_product =".$product->id; + 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; @@ -162 +144,2 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { @@ -170 +153,2 @@ - if ($result) { + if ($result) + { @@ -173,29 +157,18 @@ - $option = '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } - - print ''."\n"; - print ''; - if (!empty($sortfield)) { - print ''; - } - if (!empty($sortorder)) { - print ''; - } - - print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } - - $i = 0; - print '
'; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + + print ''."\n"; + + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + + print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) $option .= '&page='.urlencode($page); + + $i = 0; + print '
'; @@ -217,2 +190,4 @@ - if ($num > 0) { - while ($i < min($num, $limit)) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { @@ -248 +223,3 @@ - } else { + } + else + { @@ -253 +230,3 @@ -} else { +} +else +{ --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_facture.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_facture.php @@ -28 +27,0 @@ -// Load Dolibarr environment @@ -45,3 +44,2 @@ -if (!empty($user->socid)) { - $socid = $user->socid; -} +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -51,6 +48,0 @@ -$extrafields = new ExtraFields($db); - -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label('facture'); - -$search_array_options = $extrafields->getOptionalsFromPost('facture', '', 'search_'); @@ -61,3 +53,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -65,3 +57 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -71,2 +61,9 @@ -if (!$sortorder) { - $sortorder = "DESC"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.datef"; + +$search_month = GETPOST('search_month', 'alpha'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; @@ -74,43 +71 @@ -if (!$sortfield) { - $sortfield = "f.datef"; -} - -$search_date_startday = GETPOSTINT('search_date_startday'); -if (!empty($search_date_startday)) { - $option .= '&search_date_startday='.$search_date_startday; -} -$search_date_startmonth = GETPOSTINT('search_date_startmonth'); -if (!empty($search_date_startmonth)) { - $option .= '&search_date_startmonth='.$search_date_startmonth; -} -$search_date_startyear = GETPOSTINT('search_date_startyear'); -if (!empty($search_date_startyear)) { - $option .= '&search_date_startyear='.$search_date_startyear; -} -$search_date_endday = GETPOSTINT('search_date_endday'); -if (!empty($search_date_endday)) { - $option .= '&search_date_endday='.$search_date_endday; -} -$search_date_endmonth = GETPOSTINT('search_date_endmonth'); -if (!empty($search_date_endmonth)) { - $option .= '&search_date_endmonth='.$search_date_endmonth; -} -$search_date_endyear = GETPOSTINT('search_date_endyear'); -if (!empty($search_date_endyear)) { - $option .= '&search_date_endyear='.$search_date_endyear; -} -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); - -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; - $search_date_start = ''; - $search_date_end = ''; -} - -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + @@ -129 +84,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -137,3 +93 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -144 +98,2 @@ - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) + { @@ -148 +103,2 @@ - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) + { @@ -155 +111,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -159 +116 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -162,3 +119,27 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); + + print "
"; + + print '
'; + print '
'; + + dol_fiche_end(); + + if ($showmessage && $nboflines > 1) + { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; @@ -166,149 +147,61 @@ - - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - print '
'; - - print '
'; - print ''; - - $nboflines = show_stats_for_company($product, $socid); - - print "
"; - - print '
'; - print '
'; - - print dol_get_fiche_end(); - - if ($showmessage && $nboflines > 1) { - print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; - } elseif ($user->hasRight('facture', 'lire')) { - $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; - $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; - $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", sc.fk_soc, sc.fk_user "; - } - // Add fields from extrafields - if (!empty($extrafields->attributes['facture']['label'])) { - foreach ($extrafields->attributes['facture']['label'] as $key => $val) { - $sql .= ($extrafields->attributes['facture']['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } - } - // Add fields from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - $sql = preg_replace('/,\s*$/', '', $sql); - - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."facture as f"; - if (isset($extrafields->attributes['facture']['label']) && is_array($extrafields->attributes['facture']['label']) && count($extrafields->attributes['facture']['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'facture'."_extrafields as ef on (f.rowid = ef.fk_object)"; - } - $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - // Add table from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('invoice').")"; - $sql .= " AND d.fk_facture = f.rowid"; - $sql .= " AND d.fk_product = ".((int) $product->id); - if ($search_date_start) { - $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'"; - } - if ($search_date_end) { - $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND f.fk_soc = ".((int) $socid); - } - // Add where from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - // Add where from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - - // Add HAVING from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; - - $sql .= $db->order($sortfield, $sortorder); - - // Calcul total qty and amount for global if full scan list - $total_ht = 0; - $total_qty = 0; - - // Count total nb of records - $totalofrecords = ''; - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $totalofrecords = $db->num_rows($result); - } - - $sql .= $db->plimit($limit + 1, $offset); - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - - $option .= '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } - - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - // Add $param from hooks - $parameters = array('param' => &$param); - $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $option .= $hookmanager->resPrint; - - print ''."\n"; - print ''; - if (!empty($sortfield)) { - print ''; - } - if (!empty($sortorder)) { - print ''; - } - - print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } - - print '
'; - print '
'; - print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - '; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - + elseif ($user->rights->facture->lire) + { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; + $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; + $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND d.fk_facture = f.rowid"; + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + + print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) $option .= '&page='.urlencode($page); + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); @@ -317,0 +211 @@ + print '
'; @@ -320,26 +214,21 @@ - print '
'; - - $i = 0; - print '
'; - print ''; - print ''; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); - print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); - // Hook fields - $parameters = array('param'=>$option, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print "\n"; - - if ($num > 0) { - while ($i < min($num, $limit)) { - $objp = $db->fetch_object($result); - - if ($objp->type == Facture::TYPE_CREDIT_NOTE) { - $objp->qty = -($objp->qty); - } + + $i = 0; + print '
'; + print '
'; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "f.total", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) + { + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) $objp->qty = -($objp->qty); @@ -348,3 +237,3 @@ - $total_qty += $objp->qty; - - $invoicestatic->id = $objp->facid; + $total_qty += $objp->qty; + + $invoicestatic->id = $objp->facid; @@ -355,37 +244,30 @@ - print ''; - print '\n"; - print ''; - print "\n"; - print '"; - print '\n"; - print '\n"; - print ''; - // Fields from hook - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print "\n"; - $i++; - } - } - print ''; - if ($num < $limit) { - print ''; - } else { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print "
'; - print $invoicestatic->getNomUrl(1); - print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; - print dol_print_date($db->jdate($objp->datef), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5, $paiement, $objp->type).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.price($total_ht).'
"; - print '
'; - print ''; - } else { - dol_print_error($db); - } - $db->free($result); - } + print ''; + print ''; + print $invoicestatic->getNomUrl(1); + print "\n"; + print ''.$societestatic->getNomUrl(1).''; + print "".$objp->code_client."\n"; + print ''; + print dol_print_date($db->jdate($objp->datef), 'dayhour').""; + print ''.$objp->qty."\n"; + print ''.price($objp->total_ht)."\n"; + print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5, $paiement, $objp->type).''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + print ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; + print ''; + print ""; + print '
'; + print ''; + } else { + dol_print_error($db); + } + $db->free($result); + } --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_facture_fournisseur.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_facture_fournisseur.php @@ -28 +27,0 @@ -// Load Dolibarr environment @@ -45,3 +44,2 @@ -if (!empty($user->socid)) { - $socid = $user->socid; -} +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -50 +48,3 @@ -$hookmanager->initHooks(array('productstatssupplierinvoice')); +$hookmanager->initHooks(array('productstatssupplyinvoice')); + +$mesg = ''; @@ -53,3 +53,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -57,3 +57 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -63,7 +61,3 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "f.datef"; -} -$search_month = GETPOST('search_month', 'int'); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.datef"; +$search_month = GETPOST('search_month', 'alpha'); @@ -77,3 +70,0 @@ -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); - - @@ -90 +81,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -98,3 +90 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -104 +94,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -108 +99 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -111,20 +102,16 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - print '
'; - - print '
'; - print ''; - - $nboflines = show_stats_for_company($product, $socid); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); @@ -134,7 +121,8 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); - - - if ($user->hasRight('fournisseur', 'facture', 'lire')) { + print ''; + print '
'; + + dol_fiche_end(); + + + if ($user->rights->fournisseur->facture->lire) + { @@ -143 +131 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) @@ -145 +132,0 @@ - } @@ -149,3 +136 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -155,13 +140,7 @@ - $sql .= " AND d.fk_product = ".((int) $product->id); - if (!empty($search_month)) { - $sql .= ' AND MONTH(f.datef) IN ('.$db->sanitize($search_month).')'; - } - if (!empty($search_year)) { - $sql .= ' AND YEAR(f.datef) IN ('.$db->sanitize($search_year).')'; - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND f.fk_soc = ".((int) $socid); - } + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; @@ -176 +155,2 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { @@ -184 +164,2 @@ - if ($result) { + if ($result) + { @@ -187,11 +168,4 @@ - $option .= '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); @@ -200,2 +174 @@ - print ''; - if (!empty($sortfield)) { + if (!empty($sortfield)) @@ -203,2 +176 @@ - } - if (!empty($sortorder)) { + if (!empty($sortorder)) @@ -206 +177,0 @@ - } @@ -210,3 +181 @@ - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } + if (!empty($page)) $option .= '&page='.urlencode($page); @@ -215 +184 @@ - print '
'; + print '
'; @@ -227 +196 @@ - print '
'; + print '
'; @@ -239,2 +208,4 @@ - if ($num > 0) { - while ($i < min($num, $limit)) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { @@ -249 +220 @@ - $supplierinvoicestatic->libelle = $objp->label; // deprecated + $supplierinvoicestatic->libelle = $objp->label; @@ -263 +234 @@ - print '
'; + print ''; @@ -273,5 +244,2 @@ - if ($num < $limit) { - print ''; - } else { - print ''; - } + if ($num < $limit) print ''; + else print ''; --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_mo.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_mo.php @@ -3 +3 @@ - * Copyright (C) 2004-2021 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur @@ -5 +4,0 @@ - * Copyright (C) 2023 Gauthier VERDOL @@ -27 +25,0 @@ -// Load Dolibarr environment @@ -32 +29,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -43,3 +40,2 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -48 +44,3 @@ -$hookmanager->initHooks(array('productstatsmo')); +$hookmanager->initHooks(array('productstatscontract')); + +$mesg = ''; @@ -51,3 +49,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -55,3 +53 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -61,16 +57,2 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "c.date_valid"; -} - -$search_month = GETPOST('search_month', 'int'); -$search_year = GETPOST('search_year', 'int'); - -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - $search_month = ''; - $search_year = ''; -} - -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "c.date_valid"; @@ -87,3 +69,3 @@ -$formother = new FormOther($db); - -if ($id > 0 || !empty($ref)) { + +if ($id > 0 || !empty($ref)) +{ @@ -97,3 +79 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -103 +83,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -107 +88 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -110,20 +91,16 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - print '
'; - - print '
'; - print '
'; + print ''; @@ -267 +238 @@ - print ''.$supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5, $supplierinvoicestatic->getSommePaiement()).''.$supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'; - - $nboflines = show_stats_for_company($product, $socid); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); @@ -133,4 +110,4 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); + print ''; + print '
'; + + dol_fiche_end(); @@ -142,4 +119,4 @@ - $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; - $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; - $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; - $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; + $sql .= ' sum('.$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; + $sql .= ' sum('.$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; + $sql .= ' sum('.$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; + $sql .= ' sum('.$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; @@ -152,10 +129,2 @@ - $sql .= " AND cd.fk_product = ".((int) $product->id); - if (!empty($search_month)) { - $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; - } - if (!empty($search_year)) { - $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; - } - if ($socid) { - $sql .= " AND s.rowid = ".((int) $socid); - } + $sql .= " AND cd.fk_product =".$product->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; @@ -172 +141,2 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { @@ -180 +150,2 @@ - if ($result) { + if ($result) + { @@ -183,41 +154,17 @@ - $option = '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } - - print ''."\n"; - print ''; - if (!empty($sortfield)) { - print ''; - } - if (!empty($sortorder)) { - print ''; - } - - print_barre_liste($langs->trans("MOs"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); - - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } - - print '
'; - print '
'; - print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; - print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); - print '
'; - print ''; - print ''; - print '
'; - print '
'; - print '
'; - - $i = 0; - print '
'; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); + + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + + print_barre_liste($langs->trans("Mos"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) $option .= '&page='.urlencode($page); + + $i = 0; + print '
'; @@ -235 +181,0 @@ - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "b.status", "", "&id=".$product->id, '', $sortfield, $sortorder, 'right '); @@ -240,2 +186,4 @@ - if ($num > 0) { - while ($i < min($num, $limit)) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { @@ -246 +193,0 @@ - $motmp->status = $objp->status; @@ -261 +207,0 @@ - print '
'; @@ -270 +216,3 @@ - } else { + } + else + { @@ -275 +223,3 @@ -} else { +} +else +{ --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_propal.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_propal.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -44,3 +43 @@ -if (!empty($user->socid)) { - $socid = $user->socid; -} +if (!empty($user->socid)) $socid = $user->socid; @@ -51,0 +49,2 @@ +$mesg = ''; + @@ -53,3 +52,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -57,3 +56 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -63,8 +60,4 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "p.datep"; -} - -$search_month = GETPOST('search_month', 'int'); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.datep"; + +$search_month = GETPOST('search_month', 'alpha'); @@ -78,3 +70,0 @@ -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); - - @@ -91 +81,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -95 +86 @@ - $object = $product; + $object = $product; @@ -99,3 +90 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -105 +94,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -109 +99 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -112,20 +102,16 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - print '
'; - - print '
'; - print '
'.$motmp->getLibStatut(2).'
'; - - $nboflines = show_stats_for_company($product, $socid); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); @@ -135,7 +121,8 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); - - - if ($user->hasRight('propal', 'lire')) { + print ''; + print '
'; + + dol_fiche_end(); + + + if ($user->rights->propale->lire) + { @@ -145 +132 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) @@ -147 +133,0 @@ - } @@ -151 +137 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) @@ -153 +138,0 @@ - } @@ -157,13 +142,9 @@ - $sql .= " AND d.fk_product = ".((int) $product->id); - if (!empty($search_month)) { - $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')'; - } - if (!empty($search_year)) { - $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')'; - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND p.fk_soc = ".((int) $socid); - } + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) + $sql .= " AND p.fk_soc = ".$socid; @@ -178 +159,2 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { @@ -186 +168,2 @@ - if ($result) { + if ($result) + { @@ -189,11 +172,4 @@ - $option = '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); @@ -202,2 +178 @@ - print ''; - if (!empty($sortfield)) { + if (!empty($sortfield)) @@ -205,2 +180 @@ - } - if (!empty($sortorder)) { + if (!empty($sortorder)) @@ -208 +181,0 @@ - } @@ -212,3 +185 @@ - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } + if (!empty($page)) $option .= '&page='.urlencode($page); @@ -217 +188 @@ - print '
'; + print '
'; @@ -229 +200 @@ - print '
'; + print '
'; @@ -236 +207 @@ - print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder); @@ -240,2 +211,4 @@ - if ($num > 0) { - while ($i < min($num, $limit)) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { @@ -256 +229 @@ - print '
'; + print ''; @@ -267,17 +240,14 @@ - print ''; - if ($num < $limit) { - print ''; - } else { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print "
'.$societestatic->getNomUrl(1).''.$societestatic->getNomUrl(1).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.price($total_ht).'
"; - print '
'; - print ''; - } else { - dol_print_error($db); - } - $db->free($result); + print ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + print ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; + print ''; + print ""; + print '
'; + print ''; + } else { + dol_print_error($db); + } + $db->free($result); --- /tmp/dsg/dolibarr/htdocs/product/stats/github_19.0.3_supplier_proposal.php +++ /tmp/dsg/dolibarr/htdocs/product/stats/client_supplier_proposal.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -44,3 +43,2 @@ -if (!empty($user->socid)) { - $socid = $user->socid; -} +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -49 +47,3 @@ -$hookmanager->initHooks(array('productstatssupplierpropal')); +$hookmanager->initHooks(array('productstatspropal')); + +$mesg = ''; @@ -52,3 +52,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -56,3 +56 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -62,8 +60,4 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "p.date_valid"; -} - -$search_month = GETPOST('search_month', 'int'); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.date_valid"; + +$search_month = GETPOST('search_month', 'alpha'); @@ -77,3 +70,0 @@ -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); - - @@ -90 +81,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -94 +86 @@ - $object = $product; + $object = $product; @@ -98,3 +90 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -104 +94,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -108 +99 @@ - print dol_get_fiche_head($head, 'referers', $titre, -1, $picto); + dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -111,20 +102,16 @@ - print $hookmanager->resPrint; - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - $linkback = ''.$langs->trans("BackToList").''; - - $shownav = 1; - if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { - $shownav = 0; - } - - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - - print '
'; - - print '
'; - print ''; - - $nboflines = show_stats_for_company($product, $socid); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; + + print '
'; + print '
'; + + $nboflines = show_stats_for_company($product, $socid); @@ -134,7 +121,8 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); - - - if ($user->hasRight('propal', 'lire')) { + print ''; + print '
'; + + dol_fiche_end(); + + + if ($user->rights->propale->lire) + { @@ -144 +132 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) @@ -146 +133,0 @@ - } @@ -150 +137 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) @@ -152 +138,0 @@ - } @@ -156,13 +142,9 @@ - $sql .= " AND d.fk_product = ".((int) $product->id); - if (!empty($search_month)) { - $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')'; - } - if (!empty($search_year)) { - $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')'; - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND p.fk_soc = ".((int) $socid); - } + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) + $sql .= " AND p.fk_soc = ".$socid; @@ -177 +159,2 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { @@ -185 +168,2 @@ - if ($result) { + if ($result) + { @@ -188,11 +172,4 @@ - $option = '&id='.$product->id; - - if ($limit > 0 && $limit != $conf->liste_limit) { - $option .= '&limit='.((int) $limit); - } - if (!empty($search_month)) { - $option .= '&search_month='.urlencode($search_month); - } - if (!empty($search_year)) { - $option .= '&search_year='.urlencode($search_year); - } + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); + if (!empty($id)) $option .= '&id='.$product->id; + if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month); + if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year); @@ -201,2 +178 @@ - print ''; - if (!empty($sortfield)) { + if (!empty($sortfield)) @@ -204,2 +180 @@ - } - if (!empty($sortorder)) { + if (!empty($sortorder)) @@ -207 +181,0 @@ - } @@ -211,3 +185 @@ - if (!empty($page)) { - $option .= '&page='.urlencode($page); - } + if (!empty($page)) $option .= '&page='.urlencode($page); @@ -216 +188 @@ - print '
'; + print '
'; @@ -228 +200 @@ - print '
'; + print '
'; @@ -235 +207 @@ - print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder); @@ -239,2 +211,4 @@ - if ($num > 0) { - while ($i < min($num, $limit)) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { @@ -254 +228 @@ - print '
'; + print ''; @@ -265,17 +239,14 @@ - print ''; - if ($num < $limit) { - print ''; - } else { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print "
'.$societestatic->getNomUrl(1).''.$societestatic->getNomUrl(1).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.price($total_ht).'
"; - print '
'; - print ''; - } else { - dol_print_error($db); - } - $db->free($result); + print ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + print ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; + print ''; + print ""; + print ''; + print ''; + } else { + dol_print_error($db); + } + $db->free($result);