Merge branch 'fix_5053' into api_improvement

This commit is contained in:
nka11 2016-04-28 08:31:10 +02:00
commit 932b9837fe
11 changed files with 356 additions and 73 deletions

View File

@ -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.'&nbsp;'.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').'<br>'.$text_warning, 2, 1, img_picto('', 'error'),'',2);
}
print '</td>';

View File

@ -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;
});
});
</script>';
@ -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 '<tr><td>' . $langs->trans('CreateFromRepeatableInvoice') . '</td><td>';
print '<select class="flat" name="fac_rec">';
print '<select class="flat" id="fac_rec" name="fac_rec">';
print '<option value="0" selected></option>';
while ($i < $num)
{
@ -2122,7 +2126,22 @@ if ($action == 'create')
print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')</option>';
$i ++;
}
print '</select></td></tr>';
print '</select>';
// Option to reload page to retrieve customer informations. Note, this clear other input
if (!empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE))
{
print '<script type="text/javascript">
$(document).ready(function() {
$("#fac_rec").change(function() {
var fac_rec = $(this).val();
var socid = $(\'#socid\').val();
// reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec;
});
});
</script>';
}
print '</td></tr>';
}
$db->free($resql);
} else {
@ -2402,7 +2421,7 @@ if ($action == 'create')
$langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
$numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id.($fac_rec?'&fac_rec='.$fac_rec:'')).'">' . $langs->trans("AddProject") . '</a>';
print '</td></tr>';
}

View File

@ -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;

View File

@ -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;

View File

@ -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 '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>';
print '<td>';
print $langs->trans("Comment");
print '</td></tr>';
print '</tr>';
// Title
print '<tr><td class="fieldrequired">'.$langs->trans("Title").'</td><td>';
print '<input class="flat quatrevingtpercent" type="text" name="titre" value="'.$_POST["titre"].'">';
print '</td>';
// Note
print '<td rowspan="'.$rowspan.'" valign="top">';
print '<textarea class="flat centpercent" name="note_private" wrap="soft" rows="'.ROWS_4.'"></textarea>';
print '</td></tr>';
// Note public
print '<tr><td>'.$langs->trans("NotePublic").'</td><td valign="top">';
print '<textarea class="flat centpercent" name="note_public" wrap="soft" rows="'.ROWS_4.'"></textarea>';
print '</td></tr>';
// Note private
print '<tr><td>'.$langs->trans("NotePrivate").'</td><td valign="top">';
print '<textarea class="flat centpercent" name="note_private" wrap="soft" rows="'.ROWS_4.'"></textarea>';
print '</td></tr>';
// Author
print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>";
@ -657,7 +717,7 @@ if ($action == 'create')
{
$projectid = $object->fk_project;
$langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('Project') . '</td><td>';
$numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print '</td></tr>';
@ -1029,7 +1089,15 @@ else
}
print '</td></tr>';
// Note public
print '<tr><td>';
print $form->editfieldkey($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60');
print '</td>';
print '</tr>';
// Note private
print '<tr><td>';
print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
print '</td><td colspan="5">';
@ -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 '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -1335,25 +1458,133 @@ else
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
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")).'<br><br>';
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
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 "</tr>\n";
// Filters lines
print '<tr class="liste_titre">';
// Ref
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">';
print '</td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.$search_societe.'"></td>';
}
if (! empty($arrayfields['f.total']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.$search_montant_ht.'">';
print '</td>';
}
if (! empty($arrayfields['f.tva']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.$search_montant_vat.'">';
print '</td>';
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.$search_montant_ttc.'">';
print '</td>';
}
if (! empty($arrayfields['f.frequency']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
//print '<input class="flat" type="text" size="5" name="search_frequency" value="'.$search_frequency.'">';
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
}
// Date due
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_date_when" value="'.$day_date_when.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_date_when" value="'.$month_date_when.'">';
$formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5);
print '</td>';
}
// 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 '<td class="liste_titre'.($align?' '.$align:'').'">';
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 '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
}
// 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 '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpitco=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
print $searchpitco;
print '</td>';
print "</tr>\n";
if ($num > 0)
{
$var=true;

View File

@ -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."";

View File

@ -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

View File

@ -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 '&nbsp;';
print '</td>';
}
// Limit for alert
if (! empty($arrayfields['p.seuil_stock_alerte']['checked']))
{
print '<td class="liste_titre">';
print '&nbsp;';
print '</td>';
}
// 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 '<td align="right">';
if ($objp->fk_product_type != 1)
{
print $objp->seuil_stock_alerte;
}
print '</td>';
}
// Desired stock
if (! empty($arrayfields['p.desiredstock']['checked']))
{
@ -691,7 +710,7 @@ else
}
print '</td>';
}
// Desired stock
// Lot/Serial
if (! empty($arrayfields['p.tobatch']['checked']))
{
print '<td align="center">';

View File

@ -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 '</td>';
print '<td>'.$objp->label.'</td>';

View File

@ -557,7 +557,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
//print '<td><input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td>';
print '<td><input type="checkbox" class="check" name="'.$i.'"></td>';
print '<td class="nowrap">'.$prod->getNomUrl(1, '', 16).'</td>';
print '<td class="nowrap">'.$prod->getNomUrl(1, '').'</td>';
print '<td>' . $objp->label . '<input type="hidden" name="desc' . $i . '" value="' . $objp->label . '" ></td>';

View File

@ -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')