NEW Ask the new label and new dates in confirm popup when cloning tax

This commit is contained in:
Laurent Destailleur 2019-10-31 14:06:26 +01:00
parent 8f5b0f5d4d
commit 360b3a9550
6 changed files with 86 additions and 48 deletions

View File

@ -204,7 +204,7 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Type")."</td><td>".$charge->type_libelle."</td></tr>\n";
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($charge->periode, 'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->lib."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->label."</td></tr>\n";
/*print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/

View File

@ -242,12 +242,23 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
{
$object->paye = 0;
$object->id = $object->ref = null;
$object->lib = $langs->trans("CopyOf").' '.$object->lib;
if (GETPOST('clone_for_next_month') != '')
{
$object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
if (GETPOST('clone_label', 'alphanohtml')) {
$object->label = GETPOST('clone_label', 'alphanohtml');
}
else {
$object->label = $langs->trans("CopyOf").' '.$object->label;
}
if (GETPOST('clone_for_next_month', 'int')) {
$object->periode = dol_time_plus_duree($object->periode, 1, 'm');
$object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
}
else {
$newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int'));
$newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int'));
if ($newdateperiod) $object->periode = $newdateperiod;
if ($newdateech) $object->date_ech = $newdateech;
}
if ($object->check())
@ -414,12 +425,20 @@ if ($id > 0)
// Clone confirmation
if ($action === 'clone')
{
$formclone=array(
array('type' => 'checkbox', 'name' => 'clone_for_next_month','label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1),
$formquestion=array(
array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
);
if (! empty($conf->global->TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX))
{
$formquestion[]=array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1);
}
else
{
$formquestion[]=array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1);
$formquestion[]=array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("DateDue"), 'value' => -1);
}
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formclone, 'yes');
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 2);
}
// Confirmation de la suppression de la charge

View File

@ -55,7 +55,7 @@ class ChargeSociales extends CommonObject
protected $table_ref_field = 'ref';
public $date_ech;
public $lib;
public $label;
public $type;
public $type_libelle;
public $amount;
@ -65,6 +65,11 @@ class ChargeSociales extends CommonObject
public $date_modification;
public $date_validation;
/**
* @deprecated Use label instead
*/
public $lib;
/**
* @var int account ID
*/
@ -106,7 +111,7 @@ class ChargeSociales extends CommonObject
public function fetch($id, $ref = '')
{
$sql = "SELECT cs.rowid, cs.date_ech";
$sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key";
$sql.= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key";
$sql.= ", cs.fk_account, cs.fk_mode_reglement";
$sql.= ", c.libelle";
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
@ -128,7 +133,8 @@ class ChargeSociales extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->date_ech = $this->db->jdate($obj->date_ech);
$this->lib = $obj->lib;
$this->lib = $obj->label;
$this->label = $obj->label;
$this->type = $obj->fk_type;
$this->type_libelle = $obj->libelle;
$this->fk_account = $obj->fk_account;
@ -203,7 +209,7 @@ class ChargeSociales extends CommonObject
$sql.= " VALUES (".$this->type;
$sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL');
$sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL");
$sql.= ", '".$this->db->escape($this->lib)."'";
$sql.= ", '".$this->db->escape($this->label?$this->label:$this->lib)."'";
$sql.= ", '".$this->db->idate($this->date_ech)."'";
$sql.= ", '".$this->db->idate($this->periode)."'";
$sql.= ", '".price2num($newamount)."'";
@ -323,7 +329,7 @@ class ChargeSociales extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales";
$sql.= " SET libelle='".$this->db->escape($this->lib)."'";
$sql.= " SET libelle='".$this->db->escape($this->label?$this->label:$this->lib)."'";
$sql.= ", date_ech='".$this->db->idate($this->date_ech)."'";
$sql.= ", periode='".$this->db->idate($this->periode)."'";
$sql.= ", amount='".price2num($this->amount, 'MT')."'";
@ -543,13 +549,13 @@ class ChargeSociales extends CommonObject
}
if (empty($this->ref)) $this->ref=$this->lib;
if (empty($this->ref)) $this->ref=$this->label;
$label = '<u>'.$langs->trans("ShowSocialContribution").'</u>';
if (! empty($this->ref))
$label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref;
if (! empty($this->lib))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->lib;
if (! empty($this->label))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->label;
if (! empty($this->type_libelle))
$label .= '<br><b>'.$langs->trans('Type') . ':</b> ' . $this->type_libelle;
@ -677,12 +683,12 @@ class ChargeSociales extends CommonObject
$this->ref = 'SPECIMEN';
$this->specimen=1;
$this->paye = 0;
$this->date = time();
$this->date = dol_now();
$this->date_ech=$this->date+3600*24*30;
$this->periode=$this->date+3600*24*30;
$this->amount=100;
$this->lib = 0;
$this->label = 'Social contribution label';
$this->type = 1;
$this->type_libelle = 'Social contribution label';
$this->type_libelle = 'Type of social contribution';
}
}

View File

@ -4070,13 +4070,13 @@ class Form
* @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , ))
* type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ...
* @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0'
* @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
* @param int $height Force height of box
* @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
* @param int $height Force height of box (0 = auto)
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
* @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a <form> section.
* @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form
*/
public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 210, $width = 500, $disableformtag = 0)
public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0)
{
global $langs,$conf;
global $useglobalvars;
@ -4090,6 +4090,14 @@ class Form
$newselectedchoice=empty($selectedchoice)?"no":$selectedchoice;
if ($conf->browser->layout == 'phone') $width='95%';
// Set height automatically if not defined
if (empty($height)) {
$height = 210;
if (is_array($formquestion) && count($formquestion) > 2) {
$height += ((count($formquestion) - 2) * 24);
}
}
if (is_array($formquestion) && ! empty($formquestion))
{
// First add hidden fields and value
@ -4105,7 +4113,7 @@ class Form
}
// Now add questions
$more.='<table class="paddingtopbottomonly centpercent">'."\n";
$more.='<div class="tagtable paddingtopbottomonly centpercent noborderspacing">'."\n";
if (! empty($formquestion['text'])) $more.='<tr><td colspan="2">'.$formquestion['text'].'</td></tr>'."\n";
foreach ($formquestion as $key => $input)
{
@ -4117,52 +4125,52 @@ class Form
if ($input['type'] == 'text')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td class="left"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].'</div><div class="tagtd"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></div></div>'."\n";
}
elseif ($input['type'] == 'password')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td class="left"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].'</div><div class="tagtd"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></div></div>'."\n";
}
elseif ($input['type'] == 'select')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td class="tdtop left">';
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">';
if (! empty($input['label'])) $more.=$input['label'].'</div><div class="tagtd tdtop left">';
$more.=$this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
}
elseif ($input['type'] == 'checkbox')
{
$more.='<tr>';
$more.='<td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].' </td><td class="left">';
$more.='<div class="tagtr">';
$more.='<div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].' </div><div class="tagtd">';
$more.='<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr;
if (! is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') $more.=' checked';
if (is_bool($input['value']) && $input['value']) $more.=' checked';
if (isset($input['disabled'])) $more.=' disabled';
$more.=' /></td>';
$more.='</tr>'."\n";
$more.=' /></div>';
$more.='</div>'."\n";
}
elseif ($input['type'] == 'radio')
{
$i=0;
foreach($input['values'] as $selkey => $selval)
{
$more.='<tr>';
if ($i==0) $more.='<td'.(empty($input['tdclass'])?' class="tdtop"':(' class="tdtop '.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
else $more.='<td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>&nbsp;</td>';
$more.='<td><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
$more.='<div class="tagtr">';
if ($i==0) $more.='<div class="tagtd'.(empty($input['tdclass'])?' tdtop':(' tdtop '.$input['tdclass'])).'">'.$input['label'].'</div>';
else $more.='<div clas="tagtd'.(empty($input['tdclass'])?'':(' "'.$input['tdclass'])).'">&nbsp;</div>';
$more.='<div class="tagtd"><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
if ($input['disabled']) $more.=' disabled';
$more.=' /> ';
$more.=$selval;
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
$i++;
}
}
elseif ($input['type'] == 'date')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
$more.='<td class="left">';
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">'.$input['label'].'</div>';
$more.='<div class="tagtd">';
$more.=$this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0);
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
$formquestion[] = array('name'=>$input['name'].'day');
$formquestion[] = array('name'=>$input['name'].'month');
$formquestion[] = array('name'=>$input['name'].'year');
@ -4171,21 +4179,21 @@ class Form
}
elseif ($input['type'] == 'other')
{
$more.='<tr><td'.(empty($input['tdclass'])?'':(' class="'.$input['tdclass'].'"')).'>';
if (! empty($input['label'])) $more.=$input['label'].'</td><td class="left">';
$more.='<div class="tagtr"><div class="tagtd'.(empty($input['tdclass'])?'':(' '.$input['tdclass'])).'">';
if (! empty($input['label'])) $more.=$input['label'].'</div><div class="tagtd">';
$more.=$input['value'];
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
}
elseif ($input['type'] == 'onecolumn')
{
$more.='<tr><td colspan="2" class="left">';
$more.='<div class="tagtr"><div class="tagtd">';
$more.=$input['value'];
$more.='</td></tr>'."\n";
$more.='</div></div>'."\n";
}
}
}
$more.='</table>'."\n";
$more.='</div>'."\n";
}
// JQUI method dialog is broken with jmobile, we use standard HTML.

View File

@ -2529,6 +2529,9 @@ span.tabspan {
margin: 0px !important;
padding: 0px !important;
}
.noborderspacing {
border-spacing: 0;
}
tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd
{
border: 0px;

View File

@ -2620,7 +2620,6 @@ span.tabspan {
margin-top: <?php echo ($dol_hide_topmenu?'6':'0'); ?>px;
}
.paddingrightonly {
border-collapse: collapse;
border: 0px;
@ -2633,6 +2632,9 @@ span.tabspan {
margin: 0px !important;
padding: 0px !important;
}
.noborderspacing {
border-spacing: 0;
}
tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd
{
border: 0px;