Merge remote-tracking branch 'origin/3.7' into develop

Conflicts:
	htdocs/core/tpl/objectline_create.tpl.php
	htdocs/fourn/commande/card.php
This commit is contained in:
Laurent Destailleur 2015-03-06 18:51:55 +01:00
commit a1567778ab
5 changed files with 66 additions and 58 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

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

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

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

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);
}
}