dev_importproduct_measuringunit

Conflicts:
	htdocs/margin/agentMargins.php
	htdocs/product/stock/movement_card.php
	htdocs/projet/tasks/time.php
	htdocs/resource/class/html.formresource.class.php
This commit is contained in:
florian HENRY 2019-02-13 12:52:07 +01:00
commit dd9896516b
6 changed files with 219 additions and 207 deletions

View File

@ -214,9 +214,9 @@ if ($action == 'add')
$menu->target=GETPOST('target', 'alpha');
$menu->user=GETPOST('user', 'alpha');
$menu->mainmenu=GETPOST('propertymainmenu', 'alpha');
if (is_numeric(GETPOST('menuId', 'int')))
if (is_numeric(GETPOST('menuId', 'alpha')))
{
$menu->fk_menu=GETPOST('menuId', 'int');
$menu->fk_menu=GETPOST('menuId', 'alpha');
}
else
{

View File

@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
$langs->loadLangs(array("accountancy","bills"));
@ -59,7 +60,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="f.datef,f.rowid"; // Set here default search field
if (! $sortfield) $sortfield="date,item"; // Set here default search field
if (! $sortorder) $sortorder="DESC";
@ -69,7 +70,7 @@ $arrayfields=array(
);
// Security check
if (empty($conf->compta->enabled) && empty($conf->accounting->enabled)) {
if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->societe_id > 0)
@ -94,26 +95,34 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) {
$sql="SELECT rowid as id, ref as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture";
$sql.=" WHERE datef between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'InvoiceSupplier' as item FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql.=" WHERE datef between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date,'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport";
$sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport";
$sql.=" WHERE date_fin between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT rowid as id, ref,paid,amount as total_ttc, '0' as fk_soc, datedon as date,'Donation' as item FROM ".MAIN_DB_PREFIX."don";
$sql.=" SELECT rowid as id, ref,paid,amount as total_ttc, '0' as fk_soc, datedon as date, 'Donation' as item FROM ".MAIN_DB_PREFIX."don";
$sql.=" WHERE datedon between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".Don::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date,'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary";
$sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date, 'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary";
$sql.=" WHERE datep between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
$sql.=" UNION ALL";
$sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales";
$sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales";
$sql.=" WHERE date_creation between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
//$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
$sql.= $db->order($sortfield, $sortorder);
$resd = $db->query($sql);
$files=array();
$link='';
@ -128,7 +137,7 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) {
$upload_dir ='';
$i=0;
while($i<$numd)
while ($i < $numd)
{
$objd = $db->fetch_object($resd);
@ -139,18 +148,18 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) {
$upload_dir = $conf->facture->dir_output.'/'.$subdir;
$link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "InvoiceSupplier":
case "SupplierInvoice":
$tmpinvoicesupplier->fetch($objd->id);
$subdir=get_exdir(0, 0, 0, 1, $tmpinvoicesupplier, 'invoice_supplier').'/'.dol_sanitizeFileName($objd->ref);
$subdir=get_exdir($tmpinvoicesupplier->id, 2, 0, 0, $tmpinvoicesupplier, 'invoice_supplier').'/'.dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
$link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "Expense":
case "ExpenseReport":
$subdir=dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
$link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
break;
case "Salary":
case "SalaryPayment":
$subdir=dol_sanitizeFileName($objd->id);
$upload_dir = $conf->salaries->dir_output.'/'.$subdir;
$link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
@ -177,7 +186,9 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) {
{
$result=true;
$files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1);
if (count($files)<1) {
//var_dump($upload_dir);
if (count($files) < 1)
{
$nofile['date']=$db->idate($objd->date);
$nofile['paid']=$objd->paid;
$nofile['amount']=$objd->total_ttc;
@ -220,15 +231,19 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) {
*/
//FIXME
/*
*ZIP creation
*/
*ZIP creation
*/
if ($result && $action == "dl")
{
dol_delete_file($zip);
$dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp);
dol_mkdir($dirfortmpfile);
$log='date,type,ref,total,paid,filename,item_id'."\n";
$zipname = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp).'/'.($date_start)."-".($date_stop).'_export.zip';
$zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip';
dol_delete_file(name);
$zip = new ZipArchive;
$res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE);
@ -236,8 +251,8 @@ if ($result && $action == "dl")
{
foreach ($filesarray as $key=> $file)
{
if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); //
$log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n";
if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); //
$log.=dol_print_date($file['date'], 'dayrfc').','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n";
}
$zip->addFromString('transactions.csv', $log);
$zip->close();
@ -259,50 +274,63 @@ if ($result && $action == "dl")
* View
*/
$form = new Form($db);
$userstatic=new User($db);
$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List");
llxHeader('', $title, $help_url);
$h=0;
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
$head[$h][1] = $langs->trans("AccountantFiles");
$head[$h][2] = 'AccountantFiles';
$head[$h][1] = $langs->trans("AccountancyFiles");
$head[$h][2] = 'AccountancyFiles';
dol_fiche_head($head, 'AccountancyFiles');
dol_fiche_head($head, 'AccountantFiles');
$form = new Form($db);
$userstatic=new User($db);
$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List");
print '<form name="searchfiles" action="?action=searchfiles'.$tail.'" method="POST" >'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0);
print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n</a>";
// Multicompany
/*if (! empty($conf->multicompany->enabled) && is_object($mc))
{
print '<br>';
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
if (method_exists($mc, 'formObjectOptions'))
{
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode
{
print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($entity);
print "</td></tr>\n";
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
$object = new stdClass();
// Other attributes
$parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit');
}
}*/
if (! empty($conf->multicompany->enabled) && is_object($mc))
{
print '<br>';
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
if (method_exists($mc, 'formObjectOptions'))
{
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode
{
print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($entity);
print "</td></tr>\n";
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
/*$object = new stdClass();
// Other attributes
$parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit');
}*/
print ' &nbsp; - &nbsp; '.$langs->trans("Entity").' : ';
$mc->dao->getEntities();
$mc->dao->fetch($conf->entity);
print $mc->dao->label;
print "<br>\n";
}
print '<input class="button" type="submit" value="'.$langs->trans("Refresh").'" /></form>'."\n";
dol_fiche_end();
@ -318,6 +346,7 @@ if (!empty($date_start) && !empty($date_stop))
$param.='&date_stopyear='.GETPOST('date_stopyear', 'int');
print '<form name="dl" action="?action=dl" method="POST" >'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day');
@ -352,17 +381,21 @@ if (!empty($date_start) && !empty($date_stop))
if ($result)
{
$TData = dol_sort_array($filesarray, 'date', 'ASC');
if(empty($TData)) {
if (empty($TData))
{
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td></tr>';
} else {
// Sort array by date ASC to calucalte balance
}
else
{
// Sort array by date ASC to calculate balance
$totalDebit = 0;
$totalCredit = 0;
// Balance calculation
$balance = 0;
foreach($TData as &$data1) {
if($data1['item']!='Invoice'&& $data1['item']!='Donation' ){
if ($data1['item']!='Invoice'&& $data1['item']!='Donation' ){
$data1['amount']=-$data1['amount'];
}
if ($data1['amount']>0){
@ -371,8 +404,10 @@ if (!empty($date_start) && !empty($date_stop))
$balance += $data1['amount'];
$data1['balance'] = $balance;
}
// Display array
foreach($TData as $data) {
foreach($TData as $data)
{
$html_class = '';
//if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
//elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
@ -380,7 +415,7 @@ if (!empty($date_start) && !empty($date_stop))
print "<td align=\"center\">";
print dol_print_date($data['date'], 'day');
print "</td>\n";
print '<td aling="left">'.$data['item'].'</td>';
print '<td aling="left">'.$langs->trans($data['item']).'</td>';
print '<td aling="left">'.$data['ref'].'</td>';
// File link
@ -395,6 +430,7 @@ if (!empty($date_start) && !empty($date_stop))
print '<td align="right">'.price($data['balance'])."</td>\n";
print "</tr>\n";
}
print '<tr class="liste_total">';
print '<td colspan="5">&nbsp;</td>';
print '<td align="right">'.price($totalDebit).'</td>';
@ -407,6 +443,5 @@ if (!empty($date_start) && !empty($date_stop))
print '</div>';
}
llxFooter();
$db->close();

View File

@ -225,8 +225,6 @@ if ($result)
if ($num > 0)
{
$var=true;
$group_list = array();
while ($objp = $db->fetch_object($result)) {
if ($agentid > 0) {

View File

@ -47,42 +47,38 @@ $langs->loadLangs(array('products', 'stocks', 'orders'));
if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
// Security check
$result = restrictedArea($user, 'stock');
$result=restrictedArea($user,'stock');
$id = GETPOST('id', 'int');
$id=GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$msid = GETPOST('msid', 'int');
$product_id = GETPOST("product_id");
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'movementlist';
$msid=GETPOST('msid', 'int');
$product_id=GETPOST("product_id", 'int');
$action=GETPOST('action', 'aZ09');
$cancel=GETPOST('cancel', 'alpha');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist';
$idproduct = GETPOST('idproduct', 'int');
$year = GETPOST("year");
$month = GETPOST("month");
$year = GETPOST("year", 'int');
$month = GETPOST("month", 'int');
$search_ref = GETPOST('search_ref', 'alpha');
$search_movement = GETPOST("search_movement");
$search_product_ref = trim(GETPOST("search_product_ref"));
$search_product = trim(GETPOST("search_product"));
$search_warehouse = trim(GETPOST("search_warehouse"));
$search_inventorycode = trim(GETPOST("search_inventorycode"));
$search_user = trim(GETPOST("search_user"));
$search_batch = trim(GETPOST("search_batch"));
$search_qty = trim(GETPOST("search_qty"));
$search_type_mouvement = GETPOST('search_type_mouvement', 'int');
$search_movement = GETPOST("search_movement", 'alpha');
$search_product_ref = trim(GETPOST("search_product_ref", 'alpha'));
$search_product = trim(GETPOST("search_product", 'alpha'));
$search_warehouse = trim(GETPOST("search_warehouse", 'alpha'));
$search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha'));
$search_user = trim(GETPOST("search_user", 'alpha'));
$search_batch = trim(GETPOST("search_batch", 'alpha'));
$search_qty = trim(GETPOST("search_qty", 'alpha'));
$search_type_mouvement=GETPOST('search_type_mouvement','int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$page = GETPOST("page", 'int');
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
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
$offset = $limit * $page;
if (! $sortfield)
$sortfield = "m.datem";
if (! $sortorder)
$sortorder = "DESC";
if (! $sortfield) $sortfield="m.datem";
if (! $sortorder) $sortorder="DESC";
$pdluoid=GETPOST('pdluoid', 'int');
@ -94,7 +90,7 @@ $formfile = new FormFile($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('movement');
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
$arrayfields=array(
'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
@ -122,17 +118,16 @@ $arrayfields=array(
* Actions
*/
$usercanread = $user->rights->stock->mouvement->lire;
$usercancreate = $user->rights->stock->mouvement->creer;
$usercandelete = $user->rights->stock->mouvement->supprimer;
$usercanread = (($user->rights->stock->mouvement->lire));
$usercancreate = (($user->rights->stock->mouvement->creer));
$usercandelete = (($user->rights->stock->mouvement->supprimer));
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
@ -190,24 +185,22 @@ if ($action == "correct_stock")
if ($product->hasbatch())
{
$batch=GETPOST('batch_number');
$batch=GETPOST('batch_number', 'alpha');
// $eatby=GETPOST('eatby');
// $sellby=GETPOST('sellby');
$eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
$sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
//$eatby=GETPOST('eatby');
//$sellby=GETPOST('sellby');
$eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int'));
$sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int'));
$result=$product->correct_stock_batch(
$user,
$id,
GETPOST("nbpiece", 'int'),
GETPOST("mouvement"),
GETPOST("mouvement", 'int'),
GETPOST("label", 'san_alpha'),
GETPOST('unitprice'),
$eatby,
$sellby,
$batch,
GETPOST('inventorycode'),
GETPOST('unitprice', 'alpha'),
$eatby,$sellby,$batch,
GETPOST('inventorycode', 'alpha'),
$origin_element,
$origin_id
); // We do not change value of stock for a correction
@ -218,23 +211,26 @@ if ($action == "correct_stock")
$user,
$id,
GETPOST("nbpiece", 'int'),
GETPOST("mouvement"),
GETPOST("label", 'san_alpha'),
GETPOST('unitprice'),
GETPOST('inventorycode'),
GETPOST("mouvement", 'alpha'),
GETPOST("label",'san_alpha'),
GETPOST('unitprice', 'alpha'),
GETPOST('inventorycode', 'alpha'),
$origin_element,
$origin_id
); // We do not change value of stock for a correction
}
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
} else {
$error ++;
setEventMessages($product->error, $product->errors, 'errors');
$action = 'correction';
}
if ($result > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
$error++;
setEventMessages($product->error, $product->errors, 'errors');
$action='correction';
}
}
if (! $error) $action='';
@ -258,13 +254,13 @@ if ($action == "transfert_stock" && ! $cancel)
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors');
$action='transfert';
}
if (! GETPOST("nbpiece", 'int'))
if (! GETPOST("nbpiece",'int'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors');
$error++;
$action='transfert';
}
if ($id == GETPOST("id_entrepot_destination", 'int'))
if ($id == GETPOST("id_entrepot_destination",'int'))
{
setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors');
$error++;
@ -276,7 +272,7 @@ if ($action == "transfert_stock" && ! $cancel)
$product = new Product($db);
$result=$product->fetch($product_id);
if ($product->hasbatch() && ! GETPOST("batch_number"))
if ($product->hasbatch() && ! GETPOST("batch_number", 'alpha'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors');
$error++;
@ -323,7 +319,7 @@ if ($action == "transfert_stock" && ! $cancel)
else
{
$srcwarehouseid=$id;
$batch=GETPOST('batch_number');
$batch=GETPOST('batch_number', 'alpha');
$eatby=$d_eatby;
$sellby=$d_sellby;
}
@ -338,9 +334,9 @@ if ($action == "transfert_stock" && ! $cancel)
1,
GETPOST("label", 'san_alpha'),
$pricesrc,
$eatby, $sellby, $batch,
GETPOST('inventorycode')
);
$eatby,$sellby,$batch,
GETPOST('inventorycode', 'alpha')
);
// Add stock
$result2=$product->correct_stock_batch(
$user,
@ -349,9 +345,9 @@ if ($action == "transfert_stock" && ! $cancel)
0,
GETPOST("label", 'san_alpha'),
$pricedest,
$eatby, $sellby, $batch,
GETPOST('inventorycode')
);
$eatby,$sellby,$batch,
GETPOST('inventorycode', 'alpha')
);
}
}
else
@ -360,22 +356,22 @@ if ($action == "transfert_stock" && ! $cancel)
$result1=$product->correct_stock(
$user,
$id,
GETPOST("nbpiece"),
GETPOST("nbpiece", 'int'),
1,
GETPOST("label"),
GETPOST("label", 'alpha'),
$pricesrc,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alpha')
);
// Add stock
$result2=$product->correct_stock(
$user,
GETPOST("id_entrepot_destination"),
GETPOST("nbpiece"),
GETPOST("nbpiece", 'int'),
0,
GETPOST("label"),
GETPOST("label", 'alpha'),
$pricedest,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alpha')
);
}
if (! $error && $result1 >= 0 && $result2 >= 0)
@ -451,7 +447,7 @@ $sql.= " u.login, u.photo, u.lastname, u.firstname";
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
$sql.= " ".MAIN_DB_PREFIX."product as p,";
@ -468,13 +464,13 @@ if ($id > 0) $sql.= " AND e.rowid ='".$id."'";
if ($month > 0)
{
if ($year > 0)
$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'";
$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else
$sql.= " AND date_format(m.datem, '%m') = '$month'";
}
elseif ($year > 0)
{
$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'";
if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1);
@ -491,9 +487,9 @@ if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql.= natur
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->order($sortfield,$sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@ -553,7 +549,7 @@ if ($resql)
$texte = $langs->trans("ListOfStockMovements");
if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
}
llxHeader("", $texte, $help_url);
llxHeader("",$texte,$help_url);
/*
* Show tab only if we ask a particular warehouse
@ -613,7 +609,7 @@ if ($resql)
// Value
print '<tr><td class="titlefield">'.$langs->trans("EstimatedStockValueShort").'</td><td>';
print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency);
print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency);
print "</td></tr>";
// Last movement
@ -634,7 +630,7 @@ if ($resql)
print '<tr><td>'.$langs->trans("LastMovement").'</td><td>';
if ($lastmovementdate)
{
print dol_print_date($lastmovementdate, 'dayhour');
print dol_print_date($lastmovementdate,'dayhour');
}
else
{
@ -697,9 +693,9 @@ if ($resql)
}
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($id > 0) $param.='&id='.$id;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($id > 0) $param.='&id='.urlencode($id);
if ($search_movement) $param.='&search_movement='.urlencode($search_movement);
if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode);
if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement);
@ -710,7 +706,7 @@ if ($resql)
if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined
if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined
if ($search_user) $param.='&search_user='.urlencode($search_user);
if ($idproduct > 0) $param.='&idproduct='.$idproduct;
if ($idproduct > 0) $param.='&idproduct='.urlencode($idproduct);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -747,7 +743,7 @@ if ($resql)
$moreforfilter='';
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
@ -887,7 +883,7 @@ if ($resql)
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['m.datec']['checked']))
@ -909,55 +905,38 @@ if ($resql)
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['m.rowid']['checked']))
print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['m.datem']['checked']))
print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.ref']['checked']))
print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.label']['checked']))
print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['m.batch']['checked']))
print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['pl.eatby']['checked']))
print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['pl.sellby']['checked']))
print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['e.ref']['checked']))
print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); // We are on a specific warehouse card, no filter on other should be possible
if (! empty($arrayfields['m.fk_user_author']['checked']))
print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.inventorycode']['checked']))
print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.label']['checked']))
print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.type_mouvement']['checked']))
print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['origin']['checked']))
print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.value']['checked']))
print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, 'align="right"', $sortfield, $sortorder);
if (! empty($arrayfields['m.price']['checked']))
print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, 'align="right"', $sortfield, $sortorder);
if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'],$_SERVER["PHP_SELF"],'p.label','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible
if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'],$_SERVER["PHP_SELF"], "m.type_mouvement","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters=array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['m.datec']['checked']))
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['m.tms']['checked']))
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'] ,$_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";
$arrayofuniqueproduct=array();
while ($i < min($num, $limit))
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
@ -1005,7 +984,7 @@ if ($resql)
{
// Product ref
print '<td class="nowraponall">';
print $productstatic->getNomUrl(1, 'stock', 16);
print $productstatic->getNomUrl(1,'stock',16);
print "</td>\n";
}
if (! empty($arrayfields['p.label']['checked']))
@ -1069,21 +1048,20 @@ if ($resql)
if (! empty($arrayfields['m.type_mouvement']['checked']))
{
// Type of movement
switch($objp->type_mouvement)
{
case "0":
print '<td align="center">'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</td>';
break;
case "1":
print '<td align="center">'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</td>';
break;
case "2":
print '<td align="center">'.$langs->trans('StockDecrease').'</td>';
break;
case "3":
print '<td align="center">'.$langs->trans('StockIncrease').'</td>';
break;
}
switch($objp->type_mouvement){
case "0":
print '<td align="center">'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</td>';
break;
case "1":
print '<td align="center">'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</td>';
break;
case "2":
print '<td align="center">'.$langs->trans('StockDecrease').'</td>';
break;
case "3":
print '<td align="center">'.$langs->trans('StockIncrease').'</td>';
break;
}
}
if (! empty($arrayfields['origin']['checked']))
{
@ -1136,8 +1114,8 @@ if ($resql)
$productidselected=$key;
$productlabelselected=$val;
}
$datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true);
$dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true);
$datebefore=dol_get_first_day($year?$year:strftime("%Y",time()), $month?$month:1, true);
$dateafter=dol_get_last_day($year?$year:strftime("%Y",time()), $month?$month:12, true);
$balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore);
$balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter);

View File

@ -1046,7 +1046,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
if (count($contactsofproject)>0)
{
if (in_array($user->id, $contactsofproject)) $userid = $user->id;
else $userid=$contactsofproject[0];
else $userid = $contactsofproject[0];
if ($projectstatic->public) $contactsofproject = array();
print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200');
}

View File

@ -85,7 +85,7 @@ class FormResource
$resourcestat = new Dolresource($this->db);
$resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, '');
$resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter);
if ($outputmode != 2)
{