Work on cash fence
This commit is contained in:
parent
988ba172ae
commit
e366d7d57c
@ -30,14 +30,9 @@
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
|
||||
|
||||
$langs->loadLangs(array("cashcontrol","install","cashdesk","admin"));
|
||||
$langs->loadLangs(array("cashcontrol","install","cashdesk","admin","banks"));
|
||||
|
||||
$action=GETPOST('action','aZ09');
|
||||
$id=GETPOST('id');
|
||||
|
||||
if (!$user->rights->banque->configurer)
|
||||
accessforbidden();
|
||||
|
||||
$id=GETPOST('id','int');
|
||||
$categid = GETPOST('categid');
|
||||
$label = GETPOST("label");
|
||||
@ -55,6 +50,11 @@ $pagenext = $page + 1;
|
||||
if (! $sortfield) $sortfield='b.label';
|
||||
if (! $sortorder) $sortorder='ASC';
|
||||
|
||||
if (! $user->rights->cashdesk->use && ! $user->rights->takepos->use)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -63,13 +63,29 @@ if (! $sortorder) $sortorder='ASC';
|
||||
|
||||
if ($action=="start")
|
||||
{
|
||||
$cashcontrol= new CashControl($db);
|
||||
$cashcontrol->opening=GETPOST('opening');
|
||||
if (GETPOST('posmodule')=='cashdesk') $cashcontrol->posmodule="cashdesk";
|
||||
else if (GETPOST('posmodule')=='takepos') $cashcontrol->posmodule="takepos";
|
||||
$cashcontrol->posnumber=GETPOST('posnumber');
|
||||
$id=$cashcontrol->create($user);
|
||||
$action="view";
|
||||
$error=0;
|
||||
if (! GETPOST('posmodule','alpha') || GETPOST('posmodule','alpha') == '-1')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Module")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
if (GETPOST('opening','alpha') == '')
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InitialBankBalance")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$cashcontrol= new CashControl($db);
|
||||
$cashcontrol->opening=GETPOST('opening');
|
||||
if (GETPOST('posmodule')=='cashdesk') $cashcontrol->posmodule="cashdesk";
|
||||
else if (GETPOST('posmodule')=='takepos') $cashcontrol->posmodule="takepos";
|
||||
$cashcontrol->posnumber=GETPOST('posnumber');
|
||||
$id=$cashcontrol->create($user);
|
||||
$action="view";
|
||||
}
|
||||
}
|
||||
|
||||
if ($action=="close")
|
||||
@ -96,12 +112,58 @@ if ($action=="create")
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Module").'</td>';
|
||||
print '<td>'.$langs->trans("CashDesk").' ID</td>';
|
||||
print '<td>'.$langs->trans("Year").'</td>';
|
||||
print '<td>'.$langs->trans("Month").'</td>';
|
||||
print '<td>'.$langs->trans("Day").'</td>';
|
||||
print '<td>'.$langs->trans("InitialBankBalance").'</td>';
|
||||
print '<td></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$now=dol_now();
|
||||
$syear = dol_print_date($now, "%Y");
|
||||
$smonth = dol_print_date($now, "%m");
|
||||
$sday = dol_print_date($now, "%d");
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$form->selectarray('posmodule', $arrayofposavailable, 1).'</td>';
|
||||
print '<td>'.$form->selectarray('posmodule', $arrayofposavailable, 1, (count($arrayofposavailable)>1?1:0)).'</td>';
|
||||
print '<td><input name="posnumber" type="text" class="maxwidth50" value="0"></td>';
|
||||
// Year
|
||||
print '<td>';
|
||||
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'year" name="'.$prefix.'year">';
|
||||
|
||||
for ($year = $syear - 10; $year < $syear + 10 ; $year++)
|
||||
{
|
||||
$retstring.='<option value="'.$year.'"'.($year == $syear ? ' selected':'').'>'.$year.'</option>';
|
||||
}
|
||||
$retstring.="</select>\n";
|
||||
print $retstring;
|
||||
print '</td>';
|
||||
// Month
|
||||
print '<td>';
|
||||
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'month" name="'.$prefix.'month">';
|
||||
for ($month = 1 ; $month <= 12 ; $month++)
|
||||
{
|
||||
$retstring.='<option value="'.$month.'"'.($month == $smonth?' selected':'').'>';
|
||||
$retstring.=dol_print_date(mktime(12,0,0,$month,1,2000),"%b");
|
||||
$retstring.="</option>";
|
||||
}
|
||||
$retstring.="</select>";
|
||||
print $retstring;
|
||||
print '</td>';
|
||||
// Day
|
||||
print '<td>';
|
||||
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth50imp" id="'.$prefix.'day" name="'.$prefix.'day">';
|
||||
if ($emptydate || $set_time == -1)
|
||||
{
|
||||
$retstring.='<option value="0" selected> </option>';
|
||||
}
|
||||
for ($day = 1 ; $day <= 31; $day++)
|
||||
{
|
||||
$retstring.='<option value="'.$day.'"'.($day == $sday ? ' selected':'').'>'.$day.'</option>';
|
||||
}
|
||||
$retstring.="</select>";
|
||||
print $retstring;
|
||||
print '</td>';
|
||||
print '<td><input name="opening" type="text" class="maxwidth100" value=""></td>';
|
||||
print '<td align="center"><input type="submit" name="add" class="button" value="'.$langs->trans("Start").'"></td>';
|
||||
print '</tr>';
|
||||
@ -119,49 +181,50 @@ if (empty($action) || $action=="view")
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border tableforfield" width="100%">';
|
||||
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("Code");
|
||||
print '</td><td colspan="2">';
|
||||
print '<tr><td class="tdfieldcreate nowrap">';
|
||||
print $langs->trans("Ref");
|
||||
print '</td><td>';
|
||||
print $id;
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("DateCreationShort");
|
||||
print '</td><td colspan="2">';
|
||||
print dol_print_date($cashcontrol->date_creation, 'dayhour');
|
||||
print '</td></tr>';
|
||||
print '<tr><td valign="middle">'.$langs->trans("Module").'</td><td>';
|
||||
print $cashcontrol->posmodule;
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td valign="middle">'.$langs->trans("InitialBankBalance").'</td><td>';
|
||||
print price($cashcontrol->opening);
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("DateEnd");
|
||||
print '</td><td colspan="2">';
|
||||
print dol_print_date(strtotime($cashcontrol->year_close."-".$cashcontrol->month_close."-".$cashcontrol->day_close), 'day');
|
||||
print '</td><td>';
|
||||
print $cashcontrol->year_close."-".$cashcontrol->month_close."-".$cashcontrol->day_close;
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("Status");
|
||||
print '</td><td colspan="2">';
|
||||
print '</td><td>';
|
||||
if ($cashcontrol->status==1) print $langs->trans("Opened");
|
||||
if ($cashcontrol->status==2) print $langs->trans("Closed");
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="fichehalfright"><div class="ficheaddleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border tableforfield" width="100%">';
|
||||
|
||||
print '<tr><td valign="middle">'.$langs->trans("InitialBankBalance").'</td><td colspan="3">';
|
||||
print price($cashcontrol->opening);
|
||||
print "</td></tr>";
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("DateCreationShort");
|
||||
print '</td><td>';
|
||||
print dol_print_date($cashcontrol->date_creation, 'dayhour');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="middle">'.$langs->trans("CashDesk").' ID</td><td colspan="3">';
|
||||
print '<tr><td valign="middle">'.$langs->trans("CashDesk").' ID</td><td>';
|
||||
print $cashcontrol->posnumber;
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td valign="middle">'.$langs->trans("Module").'</td><td colspan="3">';
|
||||
print $cashcontrol->posmodule;
|
||||
print "</td></tr>";
|
||||
|
||||
print "</table>\n";
|
||||
print '</div>';
|
||||
print '</div></div>';
|
||||
|
||||
@ -166,8 +166,8 @@ if (empty($reshook))
|
||||
// Mass actions
|
||||
$objectclass='CashControl';
|
||||
$objectlabel='CashControl';
|
||||
$permtoread = ($user->rights->cashdesk->read || $user->rights->takepos->read);
|
||||
$permtodelete = ($user->rights->cashdesk->delete || $user->rights->takepos->delete);
|
||||
$permtoread = ($user->rights->cashdesk->use || $user->rights->takepos->use);
|
||||
$permtodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use);
|
||||
|
||||
//$uploaddir = '';
|
||||
//include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
|
||||
@ -58,16 +58,16 @@ class CashControl extends CommonObject
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>10),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>15),
|
||||
'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>18),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>20),
|
||||
'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>19),
|
||||
'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>24),
|
||||
'opening' =>array('type'=>'double(24,8)', 'label'=>'Opening', 'enabled'=>1, 'visible'=>1, 'position'=>25),
|
||||
'cash' =>array('type'=>'double(24,8)', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30),
|
||||
'cheque' =>array('type'=>'double(24,8)', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33),
|
||||
'card' =>array('type'=>'double(24,8)', 'label'=>'Card', 'enabled'=>1, 'visible'=>1, 'position'=>36),
|
||||
'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>50),
|
||||
'card' =>array('type'=>'double(24,8)', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36),
|
||||
'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>50),
|
||||
'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55),
|
||||
'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>60),
|
||||
'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>65),
|
||||
'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>70),
|
||||
'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>505),
|
||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>0, 'position'=>510),
|
||||
|
||||
@ -104,7 +104,7 @@ class modTakePos extends DolibarrModules
|
||||
$this->langfiles = array("cashdesk");
|
||||
$this->phpmin = array(5,4); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module
|
||||
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
||||
$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
|
||||
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
||||
//$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
|
||||
//$this->always_enabled = true; // If true, can't be disabled
|
||||
@ -195,27 +195,15 @@ class modTakePos extends DolibarrModules
|
||||
// Permissions
|
||||
$this->rights = array(); // Permission array used by this module
|
||||
|
||||
/*$r=0;
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Read myobject of TakePos'; // Permission label
|
||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2)
|
||||
$r=0;
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Create/Update myobject of TakePos'; // Permission label
|
||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2)
|
||||
$this->rights[$r][0] = 50151;
|
||||
$this->rights[$r][1] = 'Use point of sale';
|
||||
$this->rights[$r][2] = 'a';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'use';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Delete myobject of TakePos'; // Permission label
|
||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2)
|
||||
*/
|
||||
|
||||
// Main menu entries
|
||||
$this->menu = array(); // List of menus to add
|
||||
|
||||
Loading…
Reference in New Issue
Block a user