Add function block/unblock for a trip credit note

Signed-off-by: Spangaro Alexandre <alexandre.spangaro@gmail.com>
This commit is contained in:
Spangaro Alexandre 2012-01-16 03:21:25 +08:00 committed by Regis Houssin
parent 36edb00002
commit 28550dca89
4 changed files with 116 additions and 22 deletions

View File

@ -177,6 +177,7 @@ class Deplacement extends CommonObject
$sql .= " SET km = ".$this->km; // This is a distance or amount
$sql .= " , dated = '".$this->db->idate($this->date)."'";
$sql .= " , type = '".$this->type."'";
$sql .= " , fk_statut = '".$this->fk_statut."'";
$sql .= " , fk_user = ".$this->fk_user;
$sql .= " , fk_user_modif = ".$user->id;
$sql .= " , fk_soc = ".($this->socid > 0?$this->socid:'null');

View File

@ -51,6 +51,64 @@ $object = new Deplacement($db);
/*
* Actions
*/
if ($action == 'block' && $user->rights->deplacement->valider)
{
$object->fetch($id);
if ($object->fk_statut == '2') // Already blocked...
{
$mesg='<div class="error">'.$langs->trans("Error").'</div>';
$action='';
$error++;
}
else
{
$result = $object->fetch($id);
$object->fk_statut = '2';
$result = $object->update($user);
if ($result > 0)
{
Header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
$mesg=$object->error;
}
}
}
if ($action == 'unblock' && $user->rights->deplacement->unvalidate)
{
$object->fetch($id);
if ($object->fk_statut == '1') // Not blocked...
{
$mesg='<div class="error">'.$langs->trans("Error").'</div>';
$action='';
$error++;
}
else
{
$result = $object->fetch($id);
$object->fk_statut = '1';
$result = $object->update($user);
if ($result > 0)
{
Header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
$mesg=$object->error;
}
}
}
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer)
{
$result=$object->delete($id);
@ -473,23 +531,44 @@ else if ($id)
print '<div class="tabsAction">';
if ($user->rights->deplacement->creer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
if ($object->fk_statut == '2') // if blocked...
{
if ($user->rights->deplacement->unvalidate)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=unblock&id='.$id.'">'.$langs->trans('Unblock').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Unblock').'</a>';
}
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
}
if ($user->rights->deplacement->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
}
if ($object->fk_statut == '1') // If not blocked...
{
if ($user->rights->deplacement->valider)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=block&id='.$id.'">'.$langs->trans('Block').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Block').'</a>';
}
if ($user->rights->deplacement->creer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
}
if ($user->rights->deplacement->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
}
}
print '</div>';
}
}

View File

@ -90,17 +90,29 @@ class modDeplacement extends DolibarrModules
$this->rights[2][3] = 0;
$this->rights[2][4] = 'creer';
$this->rights[3][0] = 173;
$this->rights[3][0] = 173;
$this->rights[3][1] = 'Supprimer les deplacements';
$this->rights[3][2] = 'd';
$this->rights[3][3] = 0;
$this->rights[3][4] = 'supprimer';
$this->rights[4][0] = 178;
$this->rights[4][1] = 'Exporter les deplacements';
$this->rights[4][2] = 'd';
$this->rights[4][0] = 174;
$this->rights[4][1] = 'Bloquer les deplacements';
$this->rights[4][2] = 'a';
$this->rights[4][3] = 0;
$this->rights[4][4] = 'export';
$this->rights[4][4] = 'valider';
$this->rights[5][0] = 175;
$this->rights[5][1] = 'Debloquer les deplacements';
$this->rights[5][2] = 'a';
$this->rights[5][3] = 0;
$this->rights[5][4] = 'unvalidate';
$this->rights[6][0] = 178;
$this->rights[6][1] = 'Exporter les deplacements';
$this->rights[6][2] = 'd';
$this->rights[6][3] = 0;
$this->rights[6][4] = 'export';
// Exports
$r=0;

View File

@ -122,6 +122,8 @@ Modify=Modifier
Edit=Éditer
Validate=Valider
ToValidate=À valider
Block=Bloquer
Unblock=Débloquer
Save=Enregistrer
SaveAs=Enregistrer sous
TestConnection=Tester la connexion