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

This commit is contained in:
Laurent Destailleur
2015-03-14 14:30:09 +01:00
10 changed files with 165 additions and 51 deletions

View File

@@ -77,8 +77,10 @@ if ($action == 'confirm_delete' && $confirm == 'yes')
// Add social contribution // Add social contribution
if ($action == 'add' && $user->rights->tax->charges->creer) if ($action == 'add' && $user->rights->tax->charges->creer)
{ {
$dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]); $dateech=@dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
$dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]); $dateperiod=@dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
$amount=GETPOST('amount');
$actioncode=GETPOST('actioncode');
if (! $dateech) if (! $dateech)
{ {
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors');
@@ -89,12 +91,12 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors');
$action = 'create'; $action = 'create';
} }
elseif (! $_POST["actioncode"] > 0) elseif (! $actioncode > 0)
{ {
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")), 'errors');
$action = 'create'; $action = 'create';
} }
elseif (! $_POST["amount"]) elseif (empty($amount))
{ {
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")), 'errors');
$action = 'create'; $action = 'create';
@@ -103,11 +105,11 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
{ {
$chargesociales=new ChargeSociales($db); $chargesociales=new ChargeSociales($db);
$chargesociales->type=$_POST["actioncode"]; $chargesociales->type=$actioncode;
$chargesociales->lib=$_POST["label"]; $chargesociales->lib=GETPOST('label');
$chargesociales->date_ech=$dateech; $chargesociales->date_ech=$dateech;
$chargesociales->periode=$dateperiod; $chargesociales->periode=$dateperiod;
$chargesociales->amount=$_POST["amount"]; $chargesociales->amount=price2num($amount);
$id=$chargesociales->create($user); $id=$chargesociales->create($user);
if ($id <= 0) if ($id <= 0)
@@ -120,32 +122,39 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer) if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
{ {
$dateech=dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]); $dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
$dateperiod=dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]); $dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
if (! $dateech) $amount=GETPOST('amount');
{ if (! $dateech)
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors'); {
$action = 'edit'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors');
} $action = 'edit';
elseif (! $dateperiod) }
{ elseif (! $dateperiod)
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors'); {
$action = 'edit'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors');
} $action = 'edit';
}
elseif (empty($amount))
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")), 'errors');
$action = 'edit';
}
else else
{ {
$chargesociales=new ChargeSociales($db); $chargesociales=new ChargeSociales($db);
$result=$chargesociales->fetch($_GET["id"]); $result=$chargesociales->fetch($id);
$chargesociales->lib=$_POST["label"]; $chargesociales->lib=GETPOST('label');
$chargesociales->date_ech=$dateech; $chargesociales->date_ech=$dateech;
$chargesociales->periode=$dateperiod; $chargesociales->periode=$dateperiod;
$chargesociales->amount=price2num($amount);
$result=$chargesociales->update($user); $result=$chargesociales->update($user);
if ($result <= 0) if ($result <= 0)
{ {
setEventMessage($chargesociales->error, 'errors'); setEventMessage($chargesociales->error, 'errors');
} }
} }
} }
@@ -437,7 +446,15 @@ if ($id > 0)
} }
// Amount // Amount
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>'; if ($action == 'edit')
{
print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
print "</td></tr>";
}
else {
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
}
// Status // Status
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
@@ -466,7 +483,7 @@ if ($id > 0)
print "<div class=\"tabsAction\">\n"; print "<div class=\"tabsAction\">\n";
// Edit // Edit
if ($user->rights->tax->charges->creer) if ($object->paye == 0 && $user->rights->tax->charges->creer)
{ {
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$object->id&amp;action=edit\">".$langs->trans("Modify")."</a>"; print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$object->id&amp;action=edit\">".$langs->trans("Modify")."</a>";
} }
@@ -500,7 +517,7 @@ if ($id > 0)
} }
else else
{ {
/* Charge non trouv<75> */ /* Social contribution not found */
dol_print_error('',$object->error); dol_print_error('',$object->error);
} }
} }

View File

@@ -266,7 +266,8 @@ class ChargeSociales extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales";
$sql.= " SET libelle='".$this->db->escape($this->lib)."',"; $sql.= " SET libelle='".$this->db->escape($this->lib)."',";
$sql.= " date_ech='".$this->db->idate($this->date_ech)."',"; $sql.= " date_ech='".$this->db->idate($this->date_ech)."',";
$sql.= " periode='".$this->db->idate($this->periode)."'"; $sql.= " periode='".$this->db->idate($this->periode)."',";
$sql.= " amount='".price2num($this->amount,'MT')."'";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);

View File

@@ -80,6 +80,13 @@ if ($action == 'add')
$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
$action = 'create'; $action = 'create';
} }
if (GETPOST('type')=='link' && !GETPOST('param'))
{
$error++;
$langs->load("errors");
$mesg[]=$langs->trans("ErrorNoValueForLinkType");
$action = 'create';
}
if (GETPOST('type')=='radio' && !GETPOST('param')) if (GETPOST('type')=='radio' && !GETPOST('param'))
{ {
$error++; $error++;

View File

@@ -3624,6 +3624,7 @@ abstract class CommonObject
$attributeType = $extrafields->attribute_type[$attributeKey]; $attributeType = $extrafields->attribute_type[$attributeKey];
$attributeSize = $extrafields->attribute_size[$attributeKey]; $attributeSize = $extrafields->attribute_size[$attributeKey];
$attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey];
$attributeParam = $extrafields->attribute_param[$attributeKey];
switch ($attributeType) switch ($attributeType)
{ {
case 'int': case 'int':
@@ -3646,6 +3647,19 @@ abstract class CommonObject
case 'datetime': case 'datetime':
$this->array_options[$key]=$this->db->idate($this->array_options[$key]); $this->array_options[$key]=$this->db->idate($this->array_options[$key]);
break; break;
case 'link':
$param_list=array_keys($attributeParam ['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
if ($value)
{
$object->fetch(0,$value);
$this->array_options[$key]=$object->id;
}
break;
} }
} }
$this->db->begin(); $this->db->begin();

View File

@@ -6,6 +6,7 @@
* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro>
* Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -77,6 +78,7 @@ class ExtraFields
'checkbox' => 'ExtrafieldCheckBox', 'checkbox' => 'ExtrafieldCheckBox',
'radio' => 'ExtrafieldRadio', 'radio' => 'ExtrafieldRadio',
'chkbxlst' => 'ExtrafieldCheckBoxFromList', 'chkbxlst' => 'ExtrafieldCheckBoxFromList',
'link' => 'ExtrafieldLink',
); );
/** /**
@@ -187,6 +189,9 @@ class ExtraFields
} elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){
$typedb='text'; $typedb='text';
$lengthdb=''; $lengthdb='';
} elseif ($type=='link') {
$typedb='int';
$lengthdb='11';
} else { } else {
$typedb=$type; $typedb=$type;
$lengthdb=$length; $lengthdb=$length;
@@ -404,6 +409,9 @@ class ExtraFields
} elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) { } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) {
$typedb='text'; $typedb='text';
$lengthdb=''; $lengthdb='';
} elseif ($type=='link') {
$typedb='int';
$lengthdb='11';
} else { } else {
$typedb=$type; $typedb=$type;
$lengthdb=$length; $lengthdb=$length;
@@ -1043,6 +1051,19 @@ class ExtraFields
} }
$out .= '</select>'; $out .= '</select>';
} }
elseif ($type == 'link')
{
$out='';
$param_list=array_keys($param['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
$object->fetch($value);
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="20" value="'.$object->ref.'" >';
}
/* Add comments /* Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)'; if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
@@ -1268,6 +1289,21 @@ class ExtraFields
} else } else
dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
} }
elseif ($type == 'link')
{
$out='';
$param_list=array_keys($params['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
if ($value)
{
$object->fetch($value);
$value=$object->getNomUrl(3);
}
}
else else
{ {
$showsize=round($size); $showsize=round($size);

View File

@@ -48,6 +48,7 @@
else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();}
else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();} else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();}
else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}

View File

@@ -68,7 +68,7 @@ if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_ar
} }
} }
} }
elseif (($type== 'sellist') || ($type == 'chkbxlst')) elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') )
{ {
$paramlist=array_keys($param['options']); $paramlist=array_keys($param['options']);
$param_chain = $paramlist[0]; $param_chain = $paramlist[0];

View File

@@ -40,5 +40,6 @@ create table llx_product_fournisseur_price
info_bits integer NOT NULL DEFAULT 0, info_bits integer NOT NULL DEFAULT 0,
fk_user integer, fk_user integer,
fk_supplier_price_expression integer, -- Link to the rule for dynamic price calculation fk_supplier_price_expression integer, -- Link to the rule for dynamic price calculation
import_key varchar(14) -- Import key import_key varchar(14), -- Import key
delivery_time_days integer
)ENGINE=innodb; )ENGINE=innodb;

View File

@@ -22,7 +22,7 @@ create table llx_projet_task_time
fk_task integer NOT NULL, fk_task integer NOT NULL,
task_date date, -- only the day task_date date, -- only the day
task_datehour datetime, -- day + hour task_datehour datetime, -- day + hour
task_date_withhour integer DEFAULT 0; -- 0 by default, 1 if date was entered with start hour task_date_withhour integer DEFAULT 0, -- 0 by default, 1 if date was entered with start hour
task_duration double, task_duration double,
fk_user integer, fk_user integer,
thm double(24,8), thm double(24,8),

View File

@@ -148,22 +148,59 @@ if ($action == 'order' && isset($_POST['valid']))
foreach ($suppliers as $supplier) foreach ($suppliers as $supplier)
{ {
$order = new CommandeFournisseur($db); $order = new CommandeFournisseur($db);
$order->socid = $suppliersid[$i]; // Check if an order for the supplier exists
//trick to know which orders have been generated this way $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$order->source = 42; $sql.= " WHERE fk_soc = ".$suppliersid[$i];
foreach ($supplier['lines'] as $line) { $sql.= " AND source = 42 AND fk_statut = 0";
$order->lines[] = $line; $sql.= " ORDER BY date_creation DESC";
$resql = $db->query($sql);
if($resql && $db->num_rows($resql) > 0) {
$obj = $db->fetch_object($resql);
$order->fetch($obj->rowid);
foreach ($supplier['lines'] as $line) {
$result = $order->addline(
$line->desc,
$line->subprice,
$line->qty,
$line->tva_tx,
$line->localtax1_tx,
$line->localtax2_tx,
$line->fk_product,
0,
$line->ref_fourn,
$line->remise_percent,
'HT',
0,
$line->info_bits
);
}
if ($result < 0) {
$fail++;
$msg = $langs->trans('OrderFail') . "&nbsp;:&nbsp;";
$msg .= $order->error;
setEventMessage($msg, 'errors');
} else {
$id = $result;
}
} else {
$order->socid = $suppliersid[$i];
$order->fetch_thirdparty();
//trick to know which orders have been generated this way
$order->source = 42;
foreach ($supplier['lines'] as $line) {
$order->lines[] = $line;
}
$order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id;
$order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id;
$id = $order->create($user);
if ($id < 0) {
$fail++;
$msg = $langs->trans('OrderFail') . "&nbsp;:&nbsp;";
$msg .= $order->error;
setEventMessage($msg, 'errors');
}
$i++;
} }
$order->cond_reglement_id = 0;
$order->mode_reglement_id = 0;
$id = $order->create($user);
if ($id < 0) {
$fail++;
$msg = $langs->trans('OrderFail') . "&nbsp;:&nbsp;";
$msg .= $order->error;
setEventMessage($msg, 'errors');
}
$i++;
} }
if (! $fail && $id) if (! $fail && $id)