Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2015-03-10 10:12:08 +01:00
commit 2ea3eb3505
35 changed files with 454 additions and 193 deletions

View File

@ -1330,17 +1330,23 @@ class Categorie extends CommonObject
* Build thumb
*
* @param string $file Chemin du fichier d'origine
* @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
* @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
* @return void
*/
function add_thumb($file, $maxWidth = 160, $maxHeight = 120)
function add_thumb($file)
{
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ...
if (file_exists($file))
{
vignette($file,$maxWidth,$maxHeight);
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}

View File

@ -400,7 +400,7 @@ if ($id > 0)
// display amount and link to unpaid bill
$outstandigBills = $object->get_OutstandingBill();
if ($outstandigBills != 0)
print " / <a href='".DOL_URL_ROOT."/compta/facture/list.php?socid=".$object->id."&search_status=1'>".price($outstandigBills).'</a>';
print " (".$langs->trans("CurrentOutstandingBill")." <a href='".DOL_URL_ROOT."/compta/facture/list.php?socid=".$object->id."&search_status=1'>".price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency).'</a>)';
print '</td>';
print '</tr>';
}

View File

@ -182,9 +182,9 @@ if ($search_author)
{
$sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'";
}
if ($search_montant_ht)
if ($search_montant_ht != '')
{
$sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'";
$sql.= natural_search("p.total_ht", $search_montant_ht, 1);
}
if ($sall) {
$sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall);
@ -316,12 +316,12 @@ if ($result)
print '</td>';
print '<td class="liste_titre" colspan="1">&nbsp;</td>';
// Amount
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$search_montant_ht.'">';
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="6" name="search_montant_ht" value="'.$search_montant_ht.'">';
print '</td>';
// Author
print '<td class="liste_titre" align="center">';
print '<input class="flat" size="10" type="text" name="search_author" value="'.$search_author.'">';
print '<input class="flat" size="6" type="text" name="search_author" value="'.$search_author.'">';
print '</td>';
print '<td class="liste_titre" align="right">';
$formpropal->selectProposalStatus($viewstatut,1);

View File

@ -220,13 +220,13 @@ if (empty($reshook))
if ($datecommande == '') {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors');
$action = 'create';
$error ++;
$error++;
}
if ($socid < 1) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors');
$action = 'create';
$error ++;
$error++;
}
if (! $error) {
@ -350,7 +350,7 @@ if (empty($reshook))
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options);
if ($result < 0) {
$error ++;
$error++;
break;
}
@ -365,14 +365,14 @@ if (empty($reshook))
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
if ($reshook < 0)
$error ++;
$error++;
} else {
setEventMessage($srcobject->error, 'errors');
$error ++;
$error++;
}
} else {
setEventMessage($object->error, 'errors');
$error ++;
$error++;
}
} else {
// Required extrafield left blank, error message already defined by setOptionalsFromPost()
@ -408,7 +408,7 @@ if (empty($reshook))
$result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external');
if ($result < 0) {
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
$error ++;
$error++;
}
}
@ -579,24 +579,24 @@ if (empty($reshook))
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
$error++;
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
$error ++;
$error++;
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
$error ++;
$error++;
}
if ($qty == '') {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
$error++;
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
$error ++;
$error++;
}
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) {
@ -852,7 +852,7 @@ if (empty($reshook))
if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors');
$error ++;
$error++;
}
} else {
$type = GETPOST('type');
@ -861,7 +861,7 @@ if (empty($reshook))
// Check parameters
if (GETPOST('type') < 0) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors');
$error ++;
$error++;
}
}
@ -1125,10 +1125,10 @@ if (empty($reshook))
if (empty($reshook)) {
$result = $object->insertExtraFields();
if ($result < 0) {
$error ++;
$error++;
}
} else if ($reshook < 0)
$error ++;
$error++;
}
if ($error)

View File

@ -51,6 +51,7 @@ $sall=GETPOST('sall');
$socid=GETPOST('socid','int');
$search_user=GETPOST('search_user','int');
$search_sale=GETPOST('search_sale','int');
$search_total_ht=GETPOST('search_total_ht','alpha');
// Security check
$id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int'));
@ -79,6 +80,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_ref='';
$search_ref_customer='';
$search_company='';
$search_total_ht='';
$orderyear='';
$ordermonth='';
$deliverymonth='';
@ -96,6 +98,7 @@ $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/*
* View
*/
@ -198,7 +201,10 @@ if ($search_user > 0)
{
$sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
}
if ($search_total_ht != '')
{
$sql.= natural_search('c.total_ht', $search_total_ht, 1);
}
$sql.= ' ORDER BY '.$sortfield.' '.$sortorder;
$nbtotalofrecords = 0;
@ -252,7 +258,8 @@ if ($resql)
if ($search_ref_customer) $param.='&search_ref_customer='.$search_ref_customer;
if ($search_user > 0) $param.='&search_user='.$search_user;
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht;
$num = $db->num_rows($resql);
print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
$i = 0;
@ -316,7 +323,9 @@ if ($resql)
print '<input class="flat" type="text" size="1" maxlength="2" name="deliverymonth" value="'.$deliverymonth.'">';
$formother->select_year($deliveryyear?$deliveryyear:-1,'deliveryyear',1, 20, 5);
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="6" name="search_total_ht" value="'.$search_total_ht.'">';
print '</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print "</td></tr>\n";
@ -328,7 +337,8 @@ if ($resql)
$generic_commande = new Commande($db);
$generic_product = new Product($db);
while ($i < min($num,$limit)) {
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'>';

View File

@ -174,7 +174,11 @@ foreach ($accounts as $key=>$type)
$total[$acc->currency_code] += $solde;
}
}
if (! $found) print '<tr '.$bc[$var].'><td colspan="6">'.$langs->trans("None").'</td></tr>';
if (! $found)
{
$var = !$var;
print '<tr '.$bc[false].'><td colspan="6">'.$langs->trans("None").'</td></tr>';
}
// Total
foreach ($total as $key=>$solde)
{

View File

@ -1962,11 +1962,11 @@ if ($action == 'create')
// Outstanding Bill
$outstandigBills = $soc->get_OutstandingBill();
print ' (' . $langs->trans('CurrentOutstandingBill') . ': ';
print price($outstandigBills, '', $langs, 0, 0, - 1, $conf->currency);
print price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency);
if ($soc->outstanding_limit != '')
{
if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
print ' / ' . price($soc->outstanding_limit);
print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
}
print ')';
print '</td>';

View File

@ -187,13 +187,13 @@ if ($search_societe)
{
$sql .= natural_search('s.nom', $search_societe);
}
if ($search_montant_ht)
if ($search_montant_ht != '')
{
$sql.= ' AND f.total = \''.$db->escape(price2num(trim($search_montant_ht))).'\'';
$sql.= natural_search('f.total', $search_montant_ht, 1);
}
if ($search_montant_ttc)
if ($search_montant_ttc != '')
{
$sql.= ' AND f.total_ttc = \''.$db->escape(price2num(trim($search_montant_ttc))).'\'';
$sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
}
if ($search_status != '')
{
@ -263,8 +263,8 @@ if ($resql)
if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_sale > 0) $param.='&search_sale=' .$search_sale;
if ($search_user > 0) $param.='&search_user=' .$search_user;
if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_ttc) $param.='&search_montant_ttc='.$search_montant_ttc;
if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc;
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
$i = 0;
@ -323,9 +323,9 @@ if ($resql)
print '</td>';
print '<td class="liste_titre" align="left">&nbsp;</td>';
print '<td class="liste_titre" align="left"><input class="flat" type="text" name="search_societe" value="'.$search_societe.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="10" name="search_montant_ht" value="'.$search_montant_ht.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ht" value="'.$search_montant_ht.'"></td>';
print '<td class="liste_titre" align="right">&nbsp;</td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="10" name="search_montant_ttc" value="'.$search_montant_ttc.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ttc" value="'.$search_montant_ttc.'"></td>';
print '<td class="liste_titre" align="right">&nbsp;</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View File

@ -2141,7 +2141,8 @@ abstract class CommonObject
$fieldstatus="fk_statut";
if ($elementTable == 'user') $fieldstatus="statut";
if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts";
if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status";
$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
$sql.= " SET ".$fieldstatus." = ".$status;
// If status = 1 = validated, update also fk_user_valid

View File

@ -452,7 +452,7 @@ class Conf
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024);
// Define list of limited modules
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,askpricesupplier,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
// Enable select2
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) $conf->global->MAIN_USE_JQUERY_MULTISELECT='select2';

View File

@ -57,11 +57,11 @@ class FormOrder
{
print '<select class="flat" name="'.$hmlname.'">';
print '<option value="-1">&nbsp;</option>';
$statustohow=array(0,1,2,3,4,5,6,9); // 7 is same label than 6. 8 does not exist.
$statustohow=array('0'=>'0','1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6,7','9'=>'9'); // 7 is same label than 6. 8 does not exist.
foreach($statustohow as $key)
foreach($statustohow as $key => $value)
{
print '<option value="'.$key.'"'.($selected == $key?' selected="selected"':'').'>';
print '<option value="'.$value.'"'.(($selected == $key || $selected == $value)?' selected="selected"':'').'>';
print CommandeFournisseur::LibStatut($key,$short);
print '</option>';
}

View File

@ -4946,34 +4946,64 @@ function dol_getmypid()
/**
* Natural search
* Generate natural SQL search string
*
* @param mixed $fields String or array of strings filled with the fields names in the SQL query
* @param string $value The value to look for (example: "keyword1 keyword2")
* @return string $res The statement to append to the SQL query
* @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query
* @param string $value The value to look for.
* If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2
* If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000"
* @param string $number 0=value is list of keywords, 1=value is a numeric test
* @return string $res The statement to append to the SQL query
*/
function natural_search($fields, $value)
function natural_search($fields, $value, $numeric=0)
{
global $db;
global $db,$langs;
if ($numeric)
{
$value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
}
$crits = explode(' ', $value);
$res = '';
if (! is_array($fields)) $fields = array($fields);
$end = count($fields);
$nboffields = count($fields);
$end2 = count($crits);
$j = 0;
foreach ($crits as $crit) {
$i = 0;
foreach ($fields as $field) {
if ( $i > 0 && $i < $end) $res .= " OR ";
$res .= $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
foreach ($crits as $crit)
{
$i = 0; $i2 = 0;
$newres = '';
foreach ($fields as $field)
{
if ($numeric)
{
$operator='=';
$newcrit = preg_replace('/([<>=]+)/','',trim($crit));
preg_match('/([<>=]+)/',trim($crit), $reg);
if ($reg[1])
{
$operator = $reg[1];
}
if ($newcrit != '')
{
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.price2num($newcrit);
$i2++; // a criteria was added to string
}
}
else
{
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
$i2++; // a criteria was added to string
}
$i++;
}
if ($end > 1) $res .= ')';
if ($j < $end2 - 1) $res .= " AND ";
if ($end > 1 && $j < $end2 - 1) $res .= '(';
if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : '');
$j++;
}
return " AND " . ($end > 1? '(' : '') . $res;
$res = " AND (" . $res . ")";
//print 'xx'.$res.'yy';
return $res;
}

View File

@ -31,7 +31,7 @@
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','askpricesupplier','commande'))) $usemargins=1;
global $forceall, $senderissupplier, $inputalsopricewithtax;
if (empty($dateSelector)) $dateSelector=0;
@ -42,8 +42,8 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
// Define colspan for button Add
$colspan = 3; // Col total ht + col edit + col delete
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
//print $object->element;
?>
<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
@ -161,12 +161,12 @@ else {
if (empty($senderissupplier))
{
$form->select_produits('', 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id);
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id);
}
else
{
$ajaxoptions=array(
'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tag will be edited with which ajax json response key
'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key
'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error'
);
@ -204,23 +204,16 @@ else {
<?php } ?>
<td align="right"><?php
if (GETPOST('prod_entry_mode') != 'predef')
{
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">0';
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
}
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">0';
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
?>
</td>
<td align="right">
<?php if (GETPOST('prod_entry_mode') != 'predef') { ?>
<input type="text" size="5" name="price_ht" id="price_ht" class="flat" value="<?php echo (isset($_POST["price_ht"])?$_POST["price_ht"]:''); ?>">
<?php } ?>
</td>
<?php if (! empty($inputalsopricewithtax)) { ?>
<td align="right">
<?php if ($object->element == 'askpricesupplier' || GETPOST('prod_entry_mode') != 'predef') { ?>
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?$_POST["price_ttc"]:''); ?>">
<?php } ?>
</td>
<?php } ?>
<td align="right"><input type="text" size="2" name="qty" id="qty" class="flat" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>">
@ -301,13 +294,13 @@ else {
</tr>
<?php
if (! empty($conf->service->enabled) && $dateSelector && GETPOST('type') != '0')
if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
else $colspan = 9;
if($this->situation_cycle_ref) $colspan++;
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
if (! empty($usemargins))
{
@ -555,6 +548,11 @@ jQuery(document).ready(function() {
if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus();
if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus();
});
<?php if (GETPOST('prod_entry_mode') == 'predef') { // When we submit with a predef product and it fails we must start with predef ?>
setforpredef();
<?php } ?>
});
/* Function to set fields from choice */
@ -582,10 +580,8 @@ function setforpredef() {
jQuery("#select_type").val(-1);
jQuery("#prod_entry_mode_free").attr('checked',false);
jQuery("#prod_entry_mode_predef").attr('checked',true);
<?php if ($object->element != 'askpricesupplier') { ?>
jQuery("#price_ht").hide();
jQuery("#title_up_ht").hide();
<?php } ?>
jQuery("#price_ht").hide();
jQuery("#title_up_ht").hide();
jQuery("#price_ttc").hide(); // May no exists
jQuery("#tva_tx").hide();
jQuery("#buying_price").show();

View File

@ -402,7 +402,7 @@ if ($id > 0 || ! empty($ref))
print '<td align="center">'.$langs->trans("KeepToShip").'</td>';
if (! empty($conf->stock->enabled))
{
print '<td align="center">'.$langs->trans("Stock").'</td>';
print '<td align="center">'.$langs->trans("RealStock").'</td>';
}
else
{

View File

@ -106,6 +106,8 @@ class CommandeFournisseur extends CommonOrder
*/
function __construct($db)
{
global $conf;
$this->db = $db;
$this->products = array();
$this->lines = array();
@ -114,7 +116,8 @@ class CommandeFournisseur extends CommonOrder
$this->statuts[0] = 'StatusOrderDraft';
$this->statuts[1] = 'StatusOrderValidated';
$this->statuts[2] = 'StatusOrderApproved';
$this->statuts[3] = 'StatusOrderOnProcess';
if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess';
else $this->statuts[3] = 'StatusOrderOnProcessWithValidation';
$this->statuts[4] = 'StatusOrderReceivedPartially';
$this->statuts[5] = 'StatusOrderReceivedAll';
$this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled
@ -1618,19 +1621,65 @@ class CommandeFournisseur extends CommonOrder
}
}
/**
* Return array of dispathed lines waiting to be approved for this order
*
* @param int $status Filter on stats (-1 = no filter, 0 = lines draft to be approved, 1 = approved lines)
* @return array Array of lines
*/
function getDispachedLines($status=-1)
{
$ret = array();
// List of already dispatched lines
$sql = "SELECT p.ref, p.label,";
$sql.= " e.rowid as warehouse_id, e.label as entrepot,";
$sql.= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p,";
$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
$sql.= " WHERE cfd.fk_commande = ".$this->id;
$sql.= " AND cfd.fk_product = p.rowid";
if ($status >= 0) $sql.=" AND cfd.status = ".$status;
$sql.= " ORDER BY cfd.rowid ASC";
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $this->db->fetch_object($resql);
if ($objp) $ret[]=array('id'=>$objp->dispatchedlineid, 'productid'=>$objp->fk_product, 'warehouseid'=>$objp->warehouse_id);
$i++;
}
}
else dol_print_error($this->db, 'Failed to execute request to get dispatched lines');
return $ret;
}
/**
* Set a delivery in database for this supplier order
*
* @param User $user User that input data
* @param date $date Date of reception
* @param string $type Type of receipt
* @param string $type Type of receipt ('tot' = total/done, 'par' = partial, 'nev' = never, 'can' = cancel)
* @param string $comment Comment
* @return int <0 if KO, >0 if OK
*/
function Livraison($user, $date, $type, $comment)
{
global $conf;
$result = 0;
$error = 0;
dol_syslog(get_class($this)."::Livraison");
if ($user->rights->fournisseur->commande->receptionner)
@ -1640,7 +1689,27 @@ class CommandeFournisseur extends CommonOrder
if ($type == 'nev') $statut = 7;
if ($type == 'can') $statut = 7;
if ($statut == 4 or $statut == 5 or $statut == 7)
if (! $error && ! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && ($type == 'tot'))
{
// If option SUPPLIER_ORDER_USE_DISPATCH_STATUS is on, we check all reception are approved to allow status "total/done"
$dispatchedlinearray=$this->getDispachedLines(0);
if (count($dispatchedlinearray) > 0)
{
$result=-1;
$error++;
$this->errors[]='ErrorCantSetReceptionToTotalDoneWithReceptionToApprove';
dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionToApprove', LOG_DEBUG);
}
}
if (! $error && ! ($statut == 4 or $statut == 5 or $statut == 7))
{
$error++;
dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR);
$result = -2;
}
if (! $error)
{
$this->db->begin();
@ -1665,11 +1734,6 @@ class CommandeFournisseur extends CommonOrder
$result = -1;
}
}
else
{
dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR);
$result = -2;
}
}
else
{

View File

@ -17,7 +17,7 @@
*/
/**
* \file dev/skeletons/commandefournisseurdispatch.class.php
* \file fourn/class/fournisseur.commande.dispatch.class.php
* \ingroup fournisseur stock
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Initialy built by build_class_from_table on 2015-02-24 10:38
@ -70,10 +70,10 @@ class CommandeFournisseurDispatch extends CommonObject
// List of language codes for status
$this->statuts[0] = 'Received';
$this->statuts[1] = 'Approved';
$this->statuts[1] = 'Verified';
$this->statuts[2] = 'Denied';
$this->statutshort[0] = 'Received';
$this->statutshort[1] = 'Approved';
$this->statutshort[1] = 'Verified';
$this->statutshort[2] = 'Denied';
return 1;
@ -494,23 +494,17 @@ class CommandeFournisseurDispatch extends CommonObject
if ($mode == 3)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut5');
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4');
}
if ($mode == 4)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut3').' '.$langs->trans($this->statuts[$statut]);
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
}
if ($mode == 5)
{
if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut==3) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut5');
if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans($this->statutshort[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),'statut4');
}
}

View File

@ -143,7 +143,7 @@ if (empty($reshook))
}
// Set incoterm
if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
if ($action == 'set_incoterms' && $user->rights->fournisseur->commande->creer)
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
@ -288,7 +288,7 @@ if (empty($reshook))
$idprod=0;
$productsupplier = new ProductFournisseur($db);
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-2; // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1)
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
if (GETPOST('idprodfournprice') > 0)
{
@ -332,12 +332,12 @@ if (empty($reshook))
$array_options
);
}
if ($idprod == -2 || $idprod == 0)
if ($idprod == -99 || $idprod == 0)
{
// Product not selected
$error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")), 'errors');
// Product not selected
$error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), 'errors');
}
if ($idprod == -1)
{
@ -734,15 +734,14 @@ if (empty($reshook))
}
}
// Receive
// Set status of reception (complete, partial, ...)
if ($action == 'livraison' && $user->rights->fournisseur->commande->receptionner)
{
if ($_POST["type"])
if (GETPOST("type") != '')
{
$date_liv = dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
$date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear"));
$result = $object->Livraison($user, $date_liv, $_POST["type"], $_POST["comment"]);
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment"));
if ($result > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
@ -754,8 +753,7 @@ if (empty($reshook))
}
else
{
dol_print_error($db,$object->error);
exit;
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
@ -2598,14 +2596,21 @@ elseif (! empty($object->id))
}
// Reopen
if (in_array($object->statut, array(2, 5, 6, 7, 9)))
if (in_array($object->statut, array(2)))
{
if ($user->rights->fournisseur->commande->commander)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>';
}
}
if (in_array($object->statut, array(5, 6, 7, 9)))
{
if ($user->rights->fournisseur->commande->commander)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
}
}
// Create bill
if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted
{

View File

@ -46,6 +46,8 @@ if (! empty($conf->productbatch->enabled)) $langs->load('productbatch');
// Security check
$id = GETPOST("id",'int');
$lineid = GETPOST('lineid', 'int');
$action = GETPOST('action');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
@ -65,7 +67,35 @@ $mesg='';
* Actions
*/
if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
if ($action == 'checkdispatchline')
{
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
$result=$supplierorderdispatch->fetch($lineid);
if (! $result) dol_print_error($db);
$result=$supplierorderdispatch->setStatut(1);
if ($result < 0)
{
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
$error++;
$action='';
}
}
if ($action == 'uncheckdispatchline')
{
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
$result=$supplierorderdispatch->fetch($lineid);
if (! $result) dol_print_error($db);
$result=$supplierorderdispatch->setStatut(0);
if ($result < 0)
{
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
$error++;
$action='';
}
}
if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
{
$commande = new CommandeFournisseur($db);
$commande->fetch($id);
@ -76,33 +106,40 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece
foreach($_POST as $key => $value)
{
if (preg_match('/^product_([0-9]+)$/i', $key, $reg))
if (preg_match('/^product_([0-9]+)$/i', $key, $reg)) // without batch module enabled
{
$numline=$reg[1] + 1; // line of product
$prod = "product_".$reg[1];
$qty = "qty_".$reg[1];
$ent = "entrepot_".$reg[1];
$pu = "pu_".$reg[1]; // This is unit price including discount
$fk_commandefourndet = "fk_commandefourndet_".$reg[1];
if (GETPOST($ent,'int') > 0)
if (GETPOST($qty) > 0) // We ask to move a qty
{
$result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), '', '', '', GETPOST($fk_commandefourndet, 'int'));
if ($result < 0)
if (! GETPOST($ent,'int') > 0)
{
setEventMessages($commande->error, $commande->errors, 'errors');
dol_syslog('No dispatch for line '.$key.' as no warehouse choosed');
$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' ' .($numline);
setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors');
$error++;
}
}
else
{
dol_syslog('No dispatch for line '.$key.' as no warehouse choosed');
$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').'' .($reg[1]-1);
setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors');
$error++;
if (! $error)
{
$result = $commande->DispatchProduct($user, GETPOST($prod,'int'),GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), '', '', '', GETPOST($fk_commandefourndet, 'int'));
if ($result < 0)
{
setEventMessages($commande->error, $commande->errors, 'errors');
$error++;
}
}
}
}
else if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) // with batch module enabled
{
//eat-by date dispatch
$numline=$reg[2] + 1; // line of product
$prod = "product_".$reg[1]."_".$reg[2];
$qty = "qty_".$reg[1]."_".$reg[2];
$ent = "entrepot_".$reg[1]."_".$reg[2];
@ -112,24 +149,25 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece
$dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1]."_".$reg[2].'month'], $_POST['dluo_'.$reg[1]."_".$reg[2].'day'], $_POST['dluo_'.$reg[1]."_".$reg[2].'year']);
$dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1]."_".$reg[2].'month'], $_POST['dlc_'.$reg[1]."_".$reg[2].'day'], $_POST['dlc_'.$reg[1]."_".$reg[2].'year']);
if (! (GETPOST($ent,'int') > 0))
if (GETPOST($qty) > 0) // We ask to move a qty
{
dol_syslog('No dispatch for line '.$key.' as no warehouse choosed');
$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').'' .($reg[1]-1);
setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors');
$error++;
}
if (! $error)
{
if (! ((GETPOST($qty) > 0) && ($_POST[$lot] || $dDLUO || $dDLC)))
if (! (GETPOST($ent,'int') > 0))
{
dol_syslog('No dispatch for line '.$key.' as qty is not set or eat-by date are not set');
$text = $langs->transnoentities('atleast1batchfield').', '.$langs->transnoentities('Line').'' .($reg[1]-1);
dol_syslog('No dispatch for line '.$key.' as no warehouse choosed');
$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' ' .($numline).'-'.($reg[1]+1);
setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors');
$error++;
}
else
if (! ($_POST[$lot] || $dDLUO || $dDLC))
{
dol_syslog('No dispatch for line '.$key.' as serial/eat-by/sellby date are not set');
$text = $langs->transnoentities('atleast1batchfield').', '.$langs->transnoentities('Line').' ' .($numline).'-'.($reg[1]+1);
setEventMessage($langs->trans('ErrorFieldRequired',$text), 'errors');
$error++;
}
if (! $error)
{
$result = $commande->dispatchProduct($user, GETPOST($prod,'int'), GETPOST($qty), GETPOST($ent,'int'), GETPOST($pu), GETPOST("comment"), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'));
if ($result < 0)
@ -511,7 +549,7 @@ if ($id > 0 || ! empty($ref))
// List of already dispatching
$sql = "SELECT p.ref, p.label,";
$sql.= " e.rowid as warehouse_id, e.label as entrepot,";
$sql.= " cfd.rowid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status";
$sql.= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p,";
$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
@ -545,7 +583,7 @@ if ($id > 0 || ! empty($ref))
print '<td></td>';
print '<td>'.$langs->trans("Warehouse").'</td>';
print '<td>'.$langs->trans("Comment").'</td>';
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) print '<td align="right">'.$langs->trans("Status").'</td>';
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) print '<td align="center" colspan="2">'.$langs->trans("Status").'</td>';
print "</tr>\n";
$var=false;
@ -553,6 +591,7 @@ if ($id > 0 || ! empty($ref))
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print "<tr ".$bc[$var].">";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a>';
@ -588,8 +627,22 @@ if ($id > 0 || ! empty($ref))
//print $supplierorderdispatch->status;
print $supplierorderdispatch->getLibStatut(5);
print '</td>';
}
// Add button to check/uncheck disaptching
print '<td align="center">';
$disabled='';
if ($commande->statut == 5) $disabled=1;
if (empty($objp->status))
{
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=checkdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Check").'</a>';
}
else
{
print '<a class="button'.($disabled?' buttonRefused':'').'" href="'.$_SERVER["PHP_SELF"]."?id=".$id."&action=uncheckdispatchline&lineid=".$objp->dispatchlineid.'">'.$langs->trans("Uncheck").'</a>';
}
print '</td>';
}
print "</tr>\n";
$i++;

View File

@ -45,7 +45,7 @@ $search_user=GETPOST('search_user');
$search_ht=GETPOST('search_ht');
$search_ttc=GETPOST('search_ttc');
$sall=GETPOST('search_all');
$search_status=(GETPOST('search_status','int')!=''?GETPOST('search_status','int'):GETPOST('statut','int'));
$search_status=(GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); // alpha and not intbecause it can be '6,7'
$page = GETPOST('page','int');
$socid = GETPOST('socid','int');
@ -100,7 +100,7 @@ $offset = $conf->liste_limit * $page ;
/*
* Mode Liste
* Mode list
*/
$sql = "SELECT s.rowid as socid, s.nom as name, cf.date_commande as dc,";
@ -130,13 +130,13 @@ if ($search_user)
{
$sql.= " AND u.login LIKE '%".$db->escape($search_user)."%'";
}
if ($search_ht)
if ($search_ht != '')
{
$sql .= " AND cf.total_ht = '".$db->escape(price2num($search_ht))."'";
$sql .= natural_search("cf.total_ht",$search_ht, 1);
}
if ($search_ttc)
if ($search_ttc != '')
{
$sql .= " AND cf.total_ttc = '".$db->escape(price2num($search_ttc))."'";
$sql .= natural_search("cf.total_ttc", $search_ttc, 1);
}
if ($sall)
{
@ -153,9 +153,9 @@ if ($search_refsupp)
{
$sql.= " AND (cf.ref_supplier LIKE '%".$db->escape($search_refsupp)."%')";
}
if ($search_status >= 0)
if ($search_status != '' && $search_status >= 0)
{
if ($search_status == 6 || $search_status == 7) $sql.=" AND cf.fk_statut IN (6,7)";
if (strstr($search_status, ',')) $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")";
else $sql.=" AND cf.fk_statut = ".$search_status;
}
@ -205,17 +205,17 @@ if ($resql)
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_ref" value="'.$search_ref.'"></td>';
print '<td class="liste_titre"><input size="8" type="text" class="flat" name="search_ref" value="'.$search_ref.'"></td>';
if (empty($conf->global->SUPPLIER_ORDER_HIDE_REF_SUPPLIER)) print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_refsupp" value="'.$search_refsupp.'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'.$search_company.'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_company" value="'.$search_company.'"></td>';
if (! empty($conf->global->PROJECT_SHOW_REF_INTO_LISTS))
{
print '<td class="liste_titre">';
print '</td>';
}
print '<td class="liste_titre"><input type="text" size="6" class="flat" name="search_user" value="'.$search_user.'"></td>';
print '<td class="liste_titre" align="right"><input type="text" size="4" class="flat" name="search_ht" value="'.$search_ht.'"></td>';
print '<td class="liste_titre" align="right"><input type="text" size="4" class="flat" name="search_ttc" value="'.$search_ttc.'"></td>';
print '<td class="liste_titre" align="right"><input type="text" size="6" class="flat" name="search_ht" value="'.$search_ht.'"></td>';
print '<td class="liste_titre" align="right"><input type="text" size="6" class="flat" name="search_ttc" value="'.$search_ttc.'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';

View File

@ -153,7 +153,7 @@ if ($search_ref)
if (is_numeric($search_ref)) $sql .= natural_search(array('fac.ref'), $search_ref);
else $sql .= natural_search('fac.ref', $search_ref);
}
if (search_ref_supplier)
if ($search_ref_supplier)
{
$sql .= natural_search('fac.ref_supplier', $search_ref_supplier);
}
@ -178,14 +178,14 @@ if ($search_company)
$sql .= natural_search('s.nom', $search_company);
}
if ($search_amount_no_tax)
if ($search_amount_no_tax != '')
{
$sql .= " AND fac.total_ht = '".$db->escape(price2num($search_amount_no_tax))."'";
$sql .= natural_search('fac.total_ht', $search_amount_no_tax, 1);
}
if ($search_amount_all_tax)
if ($search_amount_all_tax != '')
{
$sql .= " AND fac.total_ttc = '".$db->escape(price2num($search_amount_all_tax))."'";
$sql .= natural_search('fac.total_ttc', $search_amount_all_tax, 1);
}
$nbtotalofrecords = 0;
@ -270,9 +270,9 @@ if ($resql)
print '</td>';
}
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="8" name="search_amount_no_tax" value="'.$search_amount_no_tax.'">';
print '<input class="flat" type="text" size="6" name="search_amount_no_tax" value="'.$search_amount_no_tax.'">';
print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="8" name="search_amount_all_tax" value="'.$search_amount_all_tax.'">';
print '<input class="flat" type="text" size="6" name="search_amount_all_tax" value="'.$search_amount_all_tax.'">';
print '</td><td class="liste_titre" align="right">';
$liststatus=array('paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid"));
print $form->selectarray('filtre', $liststatus, $filter, 1);

View File

@ -125,7 +125,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= " ORDER BY ".$sortfield." ".$sortorder;
$sql .= $db->order($sortfield,$sortorder);
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog("fourn/product/list.php:", LOG_DEBUG);
@ -225,11 +225,11 @@ if ($resql)
if ($companystatic->id > 0) print $companystatic->getNomUrl(1,'supplier');
print '</td>';
print '<td align="right">'.price($objp->price).'</td>';
print '<td align="right">'.(isset($objp->price) ? price($objp->price) : '').'</td>';
print '<td align="right">'.$objp->qty.'</td>';
print '<td align="right">'.price($objp->unitprice).'</td>';
print '<td align="right">'.(isset($objp->unitprice) ? price($objp->unitprice) : '').'</td>';
print "</tr>\n";
$i++;

View File

@ -160,6 +160,7 @@ ErrorPriceExpressionInternal=Internal error '%s'
ErrorPriceExpressionUnknown=Unknown error '%s'
ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs
ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without batch/serial information, on a product requiring batch/serial information
ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified before being allowed to do this action
# Warnings
WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined

View File

@ -159,6 +159,7 @@ Search=Search
SearchOf=Search
Valid=Valid
Approve=Approve
Disapprove=Disapprove
ReOpen=Re-Open
Upload=Send file
ToLink=Link
@ -524,6 +525,7 @@ DateFromTo=From %s to %s
DateFrom=From %s
DateUntil=Until %s
Check=Check
Uncheck=Uncheck
Internal=Internal
External=External
Internals=Internal

View File

@ -42,6 +42,7 @@ StatusOrderCanceled=Canceled
StatusOrderDraft=Draft (needs to be validated)
StatusOrderValidated=Validated
StatusOrderOnProcess=Ordered - Standby reception
StatusOrderOnProcessWithValidation=Ordered - Standby reception or validation
StatusOrderProcessed=Processed
StatusOrderToBill=Delivered
StatusOrderToBill2=To bill

View File

@ -1250,14 +1250,14 @@ class Product extends CommonObject
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
return -3;
}
}
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
return -2;
}
}
@ -3262,11 +3262,9 @@ class Product extends CommonObject
*
* @param string $sdir Target directory
* @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...)
* @param int $maxWidth Largeur maximum que dois faire la miniature (160 by defaut)
* @param int $maxHeight Hauteur maximum que dois faire la miniature (120 by defaut)
* @return int <0 if KO, >0 if OK
*/
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
function add_photo($sdir, $file)
{
global $conf;
@ -3276,10 +3274,12 @@ class Product extends CommonObject
$dir = $sdir;
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos";
else $dir .= '/'.dol_sanitizeFileName($this->ref);
dol_mkdir($dir);
$dir_osencoded=$dir;
if (is_dir($dir_osencoded))
{
$originImage = $dir . '/' . $file['name'];
@ -3290,7 +3290,7 @@ class Product extends CommonObject
if (file_exists(dol_osencode($originImage)))
{
// Cree fichier en taille vignette
$this->add_thumb($originImage,$maxWidth,$maxHeight);
$this->add_thumb($originImage);
}
}
@ -3302,18 +3302,24 @@ class Product extends CommonObject
* Build thumb
*
* @param string $file Chemin du fichier d'origine
* @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
* @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
* @return void
*/
function add_thumb($file, $maxWidth = 160, $maxHeight = 120)
function add_thumb($file)
{
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ...
$file_osencoded=dol_osencode($file);
if (file_exists($file_osencoded))
{
vignette($file,$maxWidth,$maxHeight);
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}

View File

@ -141,9 +141,9 @@ if ($id > 0 || ! empty($ref))
$sql.= " AND d.fk_commande = c.rowid";
$sql.= " AND d.fk_product =".$product->id;
if (! empty($search_month))
$sql.= ' AND MONTH(f.datef) IN (' . $search_month . ')';
$sql.= ' AND MONTH(c.date_commande) IN (' . $search_month . ')';
if (! empty($search_year))
$sql.= ' AND YEAR(f.datef) IN (' . $search_year . ')';
$sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')';
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " ORDER BY $sortfield $sortorder ";
@ -189,12 +189,14 @@ if ($id > 0 || ! empty($ref))
print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num,$totalrecords,'');
print '<div class="liste_titre">';
print $langs->trans('Period').'('.$langs->trans("DateInvoice") .') ';
print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - ';
print $langs->trans('Month') . ':<input class="flat" type="text" size="4" name="search_month" value="' . $search_month . '"> ';
print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5);
print '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</div>';
print '</div>';
$i = 0;
print '<table class="noborder" width="100%">';

View File

@ -150,9 +150,9 @@ if ($id > 0 || ! empty($ref)) {
$sql .= " AND d.fk_commande = c.rowid";
$sql .= " AND d.fk_product =" . $product->id;
if (! empty($search_month))
$sql .= ' AND MONTH(f.datef) IN (' . $search_month . ')';
$sql .= ' AND MONTH(c.date_commande) IN (' . $search_month . ')';
if (! empty($search_year))
$sql .= ' AND YEAR(f.datef) IN (' . $search_year . ')';
$sql .= ' AND YEAR(c.date_commande) IN (' . $search_year . ')';
if (! $user->rights->societe->client->voir && ! $socid)
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
if ($socid)
@ -199,12 +199,14 @@ if ($id > 0 || ! empty($ref)) {
print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, '');
print '<div class="liste_titre">';
print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') ';
print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - ';
print $langs->trans('Month') . ':<input class="flat" type="text" size="4" name="search_month" value="' . $search_month . '"> ';
print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5);
print '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</div>';
print '</div>';
$i = 0;
print '<table class="noborder" width="100%">';

View File

@ -190,12 +190,14 @@ if ($id > 0 || ! empty($ref))
print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&amp;id=".$product->id,$sortfield,$sortorder,'',$num,$totalrecords,'');
print '<div class="liste_titre">';
print $langs->trans('Period').'('.$langs->trans("DateInvoice") .') ';
print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - ';
print $langs->trans('Month') . ':<input class="flat" type="text" size="4" name="search_month" value="' . $search_month . '"> ';
print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5);
print '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</div>';
print '</div>';
$i = 0;
print '<table class="noborder" width="100%">';

View File

@ -191,12 +191,14 @@ if ($id > 0 || ! empty($ref))
print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, '');
print '<div class="liste_titre">';
print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') ';
print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - ';
print $langs->trans('Month') . ':<input class="flat" type="text" size="4" name="search_month" value="' . $search_month . '"> ';
print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5);
print '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</div>';
print '</div>';
$i = 0;
print '<table class="noborder" width="100%">';

View File

@ -192,12 +192,14 @@ if ($id > 0 || ! empty($ref))
print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&amp;id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, '');
print '<div class="liste_titre">';
print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') ';
print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - ';
print $langs->trans('Month') . ':<input class="flat" type="text" size="4" name="search_month" value="' . $search_month . '"> ';
print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5);
print '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</div>';
print '</div>';
$i = 0;
print '<table class="noborder" width="100%">';

View File

@ -1125,6 +1125,24 @@ td.formdocbutton {padding-top:6px;}
);
color:white;
}
.button:disabled {
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
cursor: auto;
}
.buttonRefused {
pointer-events: none;
cursor: default;
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
/* ============================================================================== */
/* Tables */

View File

@ -184,6 +184,23 @@ legend { margin-bottom: 8px; }
padding: 0px 2px 0px 2px;
margin: 0px 0px 0px 0px;
}
.button:disabled {
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
cursor: auto;
}
.buttonRefused {
pointer-events: none;
cursor: default;
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
form {
padding: 0em 0em 0em 0em;
margin: 0em 0em 0em 0em;

View File

@ -209,6 +209,23 @@ legend { margin-bottom: 8px; }
padding: 0px 2px 0px 2px;
margin: 0px 0px 0px 0px;
}
.button:disabled {
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
cursor: auto;
}
.buttonRefused {
pointer-events: none;
cursor: default;
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
form {
padding: 0em 0em 0em 0em;
margin: 0em 0em 0em 0em;

View File

@ -185,6 +185,23 @@ legend { margin-bottom: 8px; }
padding: 0px 2px 0px 2px;
margin: 0px 0px 0px 0px;
}
.button:disabled {
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
cursor: auto;
}
.buttonRefused {
pointer-events: none;
cursor: default;
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
form {
padding: 0em 0em 0em 0em;
margin: 0em 0em 0em 0em;

View File

@ -361,6 +361,15 @@ fieldset { border: 1px solid #AAAAAA !important; box-shadow: 2px 2px 3px #DDD; }
-moz-box-shadow: none;
cursor: auto;
}
.buttonRefused {
pointer-events: none;
cursor: default;
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
form {
padding:0px;
margin:0px;