diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 7aa1dc481e9..26c8a5beef9 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -696,15 +696,15 @@ if ($resql) // Show shippable Icon (create subloop, so may be slow) if ($conf->stock->enabled) { + $notshippable=0; + $warning = 0; + $text_info=''; + $text_warning=''; + $nbprod=0; + $langs->load("stocks"); if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) { - $notshippable=0; - $warning = 0; - $text_info=''; - $text_warning=''; - $nbprod=0; - $numlines = count($generic_commande->lines); // Loop on each line of order for ($lig=0; $lig < $numlines; $lig++) { @@ -712,9 +712,11 @@ if ($resql) { $nbprod++; // order contains real products $generic_product->id = $generic_commande->lines[$lig]->fk_product; + + // Get local and virtual stock and store it into cache if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { $generic_product->load_stock(); - $generic_product->load_virtual_stock(); + //$generic_product->load_virtual_stock(); Already included into load_stock $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } else { @@ -722,7 +724,7 @@ if ($resql) $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } - if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code is when this option is not set, setting it create strange result + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default is when this option is not set, setting it create strange result { $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel; @@ -795,7 +797,7 @@ if ($resql) { print $form->textwithtooltip('',$text_info,2,1,$text_icon,'',2); } - if ($warning) { + if ($warning) { // Always false in default mode print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'),'',2); } print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 55f259aa2fe..66b0df5969c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -83,6 +83,7 @@ $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility +$fac_rec=GETPOST('fac_rec','int'); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -2082,8 +2083,9 @@ if ($action == 'create') $(document).ready(function() { $("#socid").change(function() { var socid = $(this).val(); + var fac_rec = $(\'#fac_rec\').val(); // reload page - window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid; + window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec; }); }); '; @@ -2098,6 +2100,8 @@ if ($action == 'create') $invoice_predefined = new FactureRec($db); $invoice_predefined->fetch(GETPOST('fac_rec','int')); + $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later + $sql = 'SELECT r.rowid, r.titre, r.total_ttc'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r'; $sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid; @@ -2111,7 +2115,7 @@ if ($action == 'create') if ($num > 0) { print '' . $langs->trans('CreateFromRepeatableInvoice') . ''; - print ''; print ''; while ($i < $num) { @@ -2122,7 +2126,22 @@ if ($action == 'create') print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')'; $i ++; } - print ''; + print ''; + // Option to reload page to retrieve customer informations. Note, this clear other input + if (!empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE)) + { + print ''; + } + print ''; } $db->free($resql); } else { @@ -2402,7 +2421,7 @@ if ($action == 'create') $langs->load('projects'); print '' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id.($fac_rec?'&fac_rec='.$fac_rec:'')).'">' . $langs->trans("AddProject") . ''; print ''; } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index b18c5bf7b48..cddd511dbe4 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -53,7 +53,7 @@ class FactureRec extends CommonInvoice var $propalid; var $date_last_gen; - var $next_gen; + var $date_when; var $nb_gen_done; var $nb_gen_max; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4dbf4b9020a..3e93df70142 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -280,24 +280,27 @@ class Facture extends CommonInvoice $this->socid = $_facrec->socid; + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; - $this->fk_account = $_facrec->fk_account; - $this->cond_reglement_id = $_facrec->cond_reglement_id; - $this->mode_reglement_id = $_facrec->mode_reglement_id; + $this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; + $this->note_private = GETPOST('note_private') ? GETPOST('note_private') : $_facrec->note_private; + $this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf; + $this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id; + $this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; + $this->fk_account = GETPOST('fk_account') > 0 ? GETPOST('fk_account') : $_facrec->fk_account; + + // Fields always coming from template $this->remise_absolue = $_facrec->remise_absolue; $this->remise_percent = $_facrec->remise_percent; $this->fk_incoterms = $_facrec->fk_incoterms; $this->location_incoterms= $_facrec->location_incoterms; - $this->note_public = $_facrec->note_public; - $this->note_private = $_facrec->note_private; - // Clean parameters if (! $this->type) $this->type = self::TYPE_STANDARD; $this->ref_client=trim($this->ref_client); $this->note_public=trim($this->note_public); $this->note_private=trim($this->note_private); - $this->note_private=dol_concatdesc($facture->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); //if (! $this->remise) $this->remise = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 2e595d45daf..b826e4f266d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load('bills'); $langs->load('compta'); @@ -50,18 +51,29 @@ if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); $projectid = GETPOST('projectid','int'); -if ($page == -1) -{ - $page = 0 ; -} +$search_ref=GETPOST('search_ref'); +$search_societe=GETPOST('search_societe'); +$search_montant_ht=GETPOST('search_montant_ht'); +$search_montant_vat=GETPOST('search_montant_vat'); +$search_montant_ttc=GETPOST('search_montant_ttc'); +$day=GETPOST('day'); +$year=GETPOST('year'); +$month=GETPOST('month'); +$day_date_when=GETPOST('day_date_when'); +$year_date_when=GETPOST('year_date_when'); +$month_date_when=GETPOST('month_date_when'); +$search_frequency=GETPOST('search_frequency'); + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page ; - -if ($sortorder == "") -$sortorder="DESC"; - -if ($sortfield == "") -$sortfield="f.datef"; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +if (! $sortorder) $sortorder='DESC'; +if (! $sortfield) $sortfield='f.titre'; +$pageprev = $page - 1; +$pagenext = $page + 1; $object = new FactureRec($db); if (($id > 0 || $ref) && $action != 'create' && $action != 'add') @@ -75,18 +87,43 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('invoicecard','globalcard')); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('facturerec'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php +$arrayfields=array( + 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), + 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), + 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), + 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), + 'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), + 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), + 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), + 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + /* * Actions */ // Set note -$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once @@ -129,7 +166,8 @@ if ($action == 'add') if (! $error) { $object->titre = GETPOST('titre', 'alpha'); - $object->note_private = GETPOST('note_private'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); $object->usenewprice = GETPOST('usenewprice'); $object->frequency = $frequency; @@ -577,6 +615,24 @@ if ($action == 'addline' && $user->rights->facture->creer) } } +// Do we click on purge search criteria ? +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=''; + $search_societe=''; + $search_montant_ht=''; + $search_montant_vat=''; + $search_montant_ttc=''; + $day=''; + $year=''; + $month=''; + $day_date_when=''; + $year_date_when=''; + $month_date_when=''; + $search_frequency=''; + $search_array_options=array(); +} + /* @@ -586,6 +642,7 @@ if ($action == 'addline' && $user->rights->facture->creer) llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec'); $form = new Form($db); +$formother = new FormOther($db); $companystatic = new Societe($db); $now = dol_now(); @@ -625,20 +682,23 @@ if ($action == 'create') // Third party print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; - print ''; - print $langs->trans("Comment"); - print ''; + print ''; // Title print ''.$langs->trans("Title").''; print ''; - print ''; - - // Note - print ''; - print ''; print ''; + // Note public + print ''.$langs->trans("NotePublic").''; + print ''; + print ''; + + // Note private + print ''.$langs->trans("NotePrivate").''; + print ''; + print ''; + // Author print "".$langs->trans("Author")."".$user->getFullName($langs).""; @@ -657,7 +717,7 @@ if ($action == 'create') { $projectid = $object->fk_project; $langs->load('projects'); - print '' . $langs->trans('Project') . ''; + print '' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); print '   id).'">' . $langs->trans("AddProject") . ''; print ''; @@ -1029,7 +1089,15 @@ else } print ''; + // Note public + print ''; + print $form->editfieldkey($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer); + print ''; + print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60'); + print ''; + print ''; + // Note private print ''; print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer); print ''; @@ -1230,7 +1298,7 @@ else if (! empty($object->lines)) { $disableedit=1; - $disablemove=1; + //$disablemove=1; $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 0); // No date selector for template invoice } @@ -1309,15 +1377,47 @@ else $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($search_ref) $sql .= natural_search('f.titre', $search_ref); + if ($search_societe) $sql .= natural_search('s.nom', $search_societe); + if ($search_frequency) $sql .= natural_search('f.frequency', $search_frequency); + if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); + if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); + if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); + if ($month > 0) + { + if ($year > 0 && empty($day)) + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + else + $sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'"; + } + else if ($year > 0) + { + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } + if ($month_date_when > 0) + { + if ($year_date_when > 0 && empty($day_date_when)) + $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'"; + else if ($year_date_when > 0 && ! empty($day_date_when)) + $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'"; + else + $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'"; + } + else if ($year_date_when > 0) + { + $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'"; + } - $nbtotalofrecords = 0; + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - + + $sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); @@ -1327,6 +1427,29 @@ else $param='&socid='.$socid; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($day) $param.='&day='.$day; + if ($month) $param.='&month='.$month; + if ($year) $param.='&year=' .$year; + if ($day_date_when) $param.='&day_date_when='.$day_date_when; + if ($month_date_when) $param.='&month_date_when='.$month_date_when; + if ($year_date_when) $param.='&year_date_when=' .$year_date_when; + if ($search_ref) $param.='&search_ref=' .$search_ref; + if ($search_societe) $param.='&search_societe=' .$search_societe; + if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; + if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; + if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; + if ($search_frequency) $param.='&search_frequency=' .$search_frequency; + if ($option) $param.="&option=".$option; + if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } + + $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); print '
'."\n"; if ($optioncss != '') print ''; @@ -1335,25 +1458,133 @@ else print ''; print ''; print ''; - - print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecord,'title_accountancy.png',0,'','',$limit); + + print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; $i = 0; print ''; print ''; - print_liste_field_titre($langs->trans("Ref")); - print_liste_field_titre($langs->trans("Company"),$_SERVER['PHP_SELF'],"s.nom","","&socid=$socid","",$sortfiled,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),'','','','','align="right"'); - print_liste_field_titre($langs->trans("AmountVAT"),'','','','','align="right"'); - print_liste_field_titre($langs->trans("AmountTTC"),'','','','','align="right"'); - print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),'','','','','align="center"'); - print_liste_field_titre($langs->trans("DateLastGeneration"),'','','','','align="center"'); - print_liste_field_titre($langs->trans("NextDateToExecution"),'','','','','align="center"'); + print_liste_field_titre($langs->trans("Ref"),$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountHT"),$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountVAT"),$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateLastGeneration"),$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("NextDateToExecution"),$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); // Field may contains ling text print "\n"; + + // Filters lines + print ''; + // Ref + if (! empty($arrayfields['f.titre']['checked'])) + { + print ''; + } + // Thirpdarty + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.total']['checked'])) + { + // Amount + print ''; + } + if (! empty($arrayfields['f.tva']['checked'])) + { + // Amount + print ''; + } + if (! empty($arrayfields['f.total_ttc']['checked'])) + { + // Amount + print ''; + } + if (! empty($arrayfields['f.frequency']['checked'])) + { + // Amount + print ''; + } + // Date invoice + if (! empty($arrayfields['f.date_last_gen']['checked'])) + { + print ''; + } + // Date due + if (! empty($arrayfields['f.date_when']['checked'])) + { + print ''; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['f.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['f.tms']['checked'])) + { + print ''; + } + // Action column + print ''; + print "\n"; + + if ($num > 0) { $var=true; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e2883081452..75e676b75c5 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -694,7 +694,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search('f.total', $search_montant_vat, 1); +if ($search_montant_vat != '') $sql.= natural_search('f.total_vat', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 819a5438eda..685a29cb8e1 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -109,8 +109,10 @@ class Product extends CommonObject var $localtax1_type; var $localtax2_type; - //! Stock + //! Stock real var $stock_reel; + //! Stock virtual + var $stock_theorique; //! Cost price var $cost_price; //! Average price value for product entry into stock (PMP) @@ -3339,15 +3341,18 @@ class Product extends CommonObject /** * Load information about stock of a product into stock_reel, stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) + * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. * - * @return int < 0 if KO, > 0 if OK - * @see load_virtual_stock, getBatchInfo + * @param string $option '', 'nobatch' = Do not load batch information, 'novirtual' = Do not load virtual stock + * @return int < 0 if KO, > 0 if OK + * @see load_virtual_stock, getBatchInfo */ - function load_stock() + function load_stock($option='') { $this->stock_reel = 0; $this->stock_warehouse = array(); - + $this->stock_theorique = 0; + $sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; @@ -3369,14 +3374,17 @@ class Product extends CommonObject $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid; - if ($this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1); + if ((! preg_match('/nobatch/', $option)) && $this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1); $this->stock_reel+=$row->reel; $i++; } } $this->db->free($result); - $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... + if (! preg_match('/novirtual/', $option)) + { + $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... + } return 1; } @@ -3388,7 +3396,8 @@ class Product extends CommonObject } /** - * Load information about objects that are delat between physical and virtual stock of a product + * Load value ->stock_theorique of a product. Property this->id must be defined. + * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. * * @return int < 0 if KO, > 0 if OK * @see load_stock, getBatchInfo diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 51e453393a0..1df8e667569 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -140,7 +140,8 @@ $arrayfields=array( 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), 'p.sellprice'=>array('label'=>$titlesellprice, 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0), @@ -425,6 +426,7 @@ else if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); @@ -499,6 +501,13 @@ else print ' '; print ''; } + // Limit for alert + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + { + print ''; + } // Desired stock if (! empty($arrayfields['p.desiredstock']['checked'])) { @@ -674,13 +683,23 @@ else if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) // To optimize call of load_stock { - if ($objp->fk_product_type != 1) + if ($objp->fk_product_type != 1) // Not a service { $product_static->id = $objp->rowid; - $product_static->load_stock(); + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse + batch detail. This also call load_virtual_stock() } } + // Limit alert + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + { + print ''; + } // Desired stock if (! empty($arrayfields['p.desiredstock']['checked'])) { @@ -691,7 +710,7 @@ else } print ''; } - // Desired stock + // Lot/Serial if (! empty($arrayfields['p.tobatch']['checked'])) { print ''; print ''; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index c31699a12ef..8fe2a7acf17 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -557,7 +557,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) //print ''; print ''; - print ''; + print ''; print ''; diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index ac9adf8f480..430cf4f0f3b 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -253,13 +253,13 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * + * @param string $website_id Web site id * @param string $sortorder Sort Order * @param string $sortfield Sort field * @param int $limit limit * @param int $offset Offset * @param array $filter Filter array * @param string $filtermode Filter mode (AND or OR) - * * @return array|int int <0 if KO, array of pages if OK */ public function fetchAll($website_id, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5); + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); + print $searchpitco; + print '
'; + print ' '; + print ''; + if ($objp->fk_product_type != 1) + { + print $objp->seuil_stock_alerte; + } + print ''; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 27f85cd90ab..57ca1adff9d 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -316,7 +316,7 @@ if ($resql) $product_static->label = $objp->label; $product_static->type=$objp->fk_product_type; $product_static->entity=$objp->entity; - print $product_static->getNomUrl(1,'',16); + print $product_static->getNomUrl(1,'',24); //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); print ''.$objp->label.''.$prod->getNomUrl(1, '', 16).''.$prod->getNomUrl(1, '').'' . $objp->label . '