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

This commit is contained in:
Laurent Destailleur 2014-10-30 19:28:43 +01:00
commit 6e0e812531
6 changed files with 68 additions and 51 deletions

View File

@ -32,9 +32,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$id=GETPOST('id', 'int'); $id=GETPOST('id', 'int');
$value=GETPOST('value', 'int'); $value=GETPOST('value', 'int');
$field=GETPOST('field', 'alpha');
$element=GETPOST('element', 'alpha');
$object = new GenericObject($db); $object = new GenericObject($db);
/* /*
* View * View
*/ */
@ -44,9 +45,5 @@ top_httphead();
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n"; print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
// Registering new values // Registering new values
if (! empty($action) && ! empty($id) && $user->rights->produit->creer) { if (($action == 'set') && ! empty($id))
if ($action == 'setstatus') $object->setValueFrom($field, $value, $element, $id);
$object->setValueFrom('tosell', $value, 'product', $id);
else if ($action == 'setstatus_buy')
$object->setValueFrom('tobuy', $value, 'product', $id);
}

View File

@ -460,35 +460,36 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0,
} }
/** /**
* On/off button for product tosell or tobuy * On/off button for object
* *
* @param int $id Id product to set * @param int $object Id product to set
* @param string $code Name of constant : status or status_buy * @param string $code Name of constant : status or status_buy for product by example
* @param string $field Name of database field : tosell or tobuy for product by example
* @param string $text_on Text if on
* @param string $text_off Text if off
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
* @return void * @return void
*/ */
function ajax_productonoff($id, $code, $input=array()) function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
{ {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; global $langs;
global $conf, $langs, $db;
$object = new Product($db);
$object->fetch($id);
$out= '<script type="text/javascript"> $out= '<script type="text/javascript">
$(function() { $(function() {
var input = '.json_encode($input).'; var input = '.json_encode($input).';
// Set constant // Set constant
$("#set_'.$code.'").click(function() { $("#set_'.$code.'_'.$object->id.'").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", { $.get( "'.DOL_URL_ROOT.'/core/ajax/objectonoff.php", {
action: \'set'.$code.'\', action: \'set\',
field: \''.$field.'\',
value: \'1\', value: \'1\',
id: \''.$id.'\' element: \''.$object->element.'\',
id: \''.$object->id.'\'
}, },
function() { function() {
$("#set_'.$code.'").hide(); $("#set_'.$code.'_'.$object->id.'").hide();
$("#del_'.$code.'").show(); $("#del_'.$code.'_'.$object->id.'").show();
// Enable another element // Enable another element
if (input.disabled && input.disabled.length > 0) { if (input.disabled && input.disabled.length > 0) {
$.each(input.disabled, function(key,value) { $.each(input.disabled, function(key,value) {
@ -508,15 +509,17 @@ function ajax_productonoff($id, $code, $input=array())
}); });
// Del constant // Del constant
$("#del_'.$code.'").click(function() { $("#del_'.$code.'_'.$object->id.'").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", { $.get( "'.DOL_URL_ROOT.'/core/ajax/objectonoff.php", {
action: \'set'.$code.'\', action: \'set\',
field: \''.$field.'\',
value: \'0\', value: \'0\',
id: \''.$id.'\' element: \''.$object->element.'\',
id: \''.$object->id.'\'
}, },
function() { function() {
$("#del_'.$code.'").hide(); $("#del_'.$code.'_'.$object->id.'").hide();
$("#set_'.$code.'").show(); $("#set_'.$code.'_'.$object->id.'").show();
// Disable another element // Disable another element
if (input.disabled && input.disabled.length > 0) { if (input.disabled && input.disabled.length > 0) {
$.each(input.disabled, function(key,value) { $.each(input.disabled, function(key,value) {
@ -536,14 +539,9 @@ function ajax_productonoff($id, $code, $input=array())
}); });
}); });
</script>'; </script>';
if ($code=='status') { $out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans($text_off),'switch_off').'</span>';
$out.= '<span id="set_'.$code.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnSell"),'switch_off').'</span>'; $out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans($text_on),'switch_on').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnSell"),'switch_on').'</span>';
}
if ($code=='status_buy') {
$out.= '<span id="set_'.$code.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans("ProductStatusNotOnBuy"),'switch_off').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans("ProductStatusOnBuy"),'switch_on').'</span>';
}
return $out; return $out;
} }

View File

@ -1420,7 +1420,7 @@ else
// Status (to sell) // Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) { if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) {
print ajax_productonoff($object->id, 'status'); print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else { } else {
print $object->getLibStatut(2,0); print $object->getLibStatut(2,0);
} }
@ -1429,7 +1429,7 @@ else
// Status (to buy) // Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) { if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) {
print ajax_productonoff($object->id, 'status_buy'); print ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else { } else {
print $object->getLibStatut(2,1); print $object->getLibStatut(2,1);
} }
@ -1438,7 +1438,11 @@ else
// Batch number management (to batch) // Batch number management (to batch)
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled) {
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Lot").')</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Lot").')</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) {
print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch');
} else {
print $object->getLibStatut(2,2); print $object->getLibStatut(2,2);
}
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -507,11 +507,25 @@ else
} }
} }
// Status (to buy) $product_static->status_buy = $objp->tobuy;
print '<td align="center" class="nowrap">'.$product_static->LibStatut($objp->tosell,5,0).'</td>'; $product_static->status = $objp->tosell;
// Status (to sell) // Status (to sell)
print '<td align="center" class="nowrap">'.$product_static->LibStatut($objp->tobuy,5,1).'</td>'; print '<td align="right" nowrap="nowrap">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) {
print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else {
print $product_static->LibStatut($objp->tosell,5,0);
}
print '</td>';
// Status (to buy)
print '<td align="right" nowrap="nowrap">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) {
print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else {
print $product_static->LibStatut($objp->tobuy,5,1);
}
print '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';

View File

@ -279,7 +279,7 @@ if ($id > 0 || $ref)
// Status (to sell) // Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) { if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) {
print ajax_productonoff($product->id, 'status'); print ajax_object_onoff($product, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else { } else {
print $product->getLibStatut(2,0); print $product->getLibStatut(2,0);
} }
@ -288,7 +288,7 @@ if ($id > 0 || $ref)
// Status (to buy) // Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) { if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer) {
print ajax_productonoff($product->id, 'status_buy'); print ajax_object_onoff($product, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else { } else {
print $product->getLibStatut(2,1); print $product->getLibStatut(2,1);
} }

View File

@ -1698,7 +1698,11 @@ else
// Status // Status
print '<tr><td>'.$langs->trans("Status").'</td>'; print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">'; print '<td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">';
if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer) {
print ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
} else {
print $object->getLibStatut(2); print $object->getLibStatut(2);
}
print '</td>'; print '</td>';
print $htmllogobar; $htmllogobar=''; print $htmllogobar; $htmllogobar='';
print '</tr>'; print '</tr>';