default envent status
This commit is contained in:
parent
0edae6e19a
commit
7d3bd131ab
@ -30,6 +30,7 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php';
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
@ -84,7 +85,31 @@ if ($action == 'set')
|
|||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
||||||
dolibarr_set_const($db, 'AGENDA_EVENT_DEFAULT_STATUS', GETPOST('AGENDA_EVENT_DEFAULT_STATUS'), 'chaine', 0, '', $conf->entity);
|
|
||||||
|
$defaultValues = new DefaultValues($db);
|
||||||
|
$result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 'entity'=>$conf->entity));
|
||||||
|
if (!is_array($result) && $result<0) {
|
||||||
|
setEventMessages($defaultValues->error,$defaultValues->errors,'errors');
|
||||||
|
} elseif(count($result)>0) {
|
||||||
|
foreach($result as $defval) {
|
||||||
|
$defaultValues->id=$defval->id;
|
||||||
|
$resultDel = $defaultValues->delete($user);
|
||||||
|
if ($resultDel<0) {
|
||||||
|
setEventMessages($defaultValues->error,$defaultValues->errors,'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$defaultValues->type='createform';
|
||||||
|
$defaultValues->entity=$conf->entity;
|
||||||
|
$defaultValues->user_id=0;
|
||||||
|
$defaultValues->page='comm/action/card.php';
|
||||||
|
$defaultValues->param='complete';
|
||||||
|
$defaultValues->value=GETPOST('AGENDA_EVENT_DEFAULT_STATUS');
|
||||||
|
$resultCreat=$defaultValues->create($user);
|
||||||
|
if ($resultCreat<0) {
|
||||||
|
setEventMessages($defaultValues->error,$defaultValues->errors,'errors');
|
||||||
|
}
|
||||||
|
|
||||||
} elseif ($action == 'specimen') // For orders
|
} elseif ($action == 'specimen') // For orders
|
||||||
{
|
{
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
@ -353,12 +378,21 @@ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
|||||||
$formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1);
|
$formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1);
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// AGENDA_EVENT_DEFAULT_STATUS
|
// AGENDA_EVENT_DEFAULT_STATUS
|
||||||
print '<tr class="oddeven">'."\n";
|
print '<tr class="oddeven">'."\n";
|
||||||
print '<td>'.$langs->trans("AGENDA_EVENT_DEFAULT_STATUS").'</td>'."\n";
|
print '<td>'.$langs->trans("AGENDA_EVENT_DEFAULT_STATUS").'</td>'."\n";
|
||||||
print '<td class="center"> </td>'."\n";
|
print '<td class="center"> </td>'."\n";
|
||||||
print '<td class="right nowrap">'."\n";
|
print '<td class="right nowrap">'."\n";
|
||||||
$formactions->form_select_status_action('agenda', $conf->global->AGENDA_EVENT_DEFAULT_STATUS, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200');
|
$defval='na';
|
||||||
|
$defaultValues = new DefaultValues($db);
|
||||||
|
$result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 'entity'=>$conf->entity));
|
||||||
|
if (!is_array($result) && $result<0) {
|
||||||
|
setEventMessages($defaultValues->error,$defaultValues->errors,'errors');
|
||||||
|
} elseif(count($result)>0) {
|
||||||
|
$defval=reset($result)->value;
|
||||||
|
}
|
||||||
|
$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200');
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
|
|
||||||
// AGENDA_DEFAULT_FILTER_TYPE
|
// AGENDA_DEFAULT_FILTER_TYPE
|
||||||
|
|||||||
@ -1050,13 +1050,11 @@ if ($action == 'create')
|
|||||||
// Status
|
// Status
|
||||||
print '<tr><td>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td>';
|
print '<tr><td>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$percent = -1;
|
|
||||||
if (GETPOSTISSET('status')) $percent = GETPOST('status');
|
if (GETPOSTISSET('status')) $percent = GETPOST('status');
|
||||||
elseif (GETPOSTISSET('percentage')) $percent = GETPOST('percentage');
|
elseif (GETPOSTISSET('percentage')) $percent = GETPOST('percentage');
|
||||||
else {
|
else {
|
||||||
if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0';
|
if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0';
|
||||||
elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100;
|
elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100;
|
||||||
elseif (isset($conf->global->AGENDA_EVENT_DEFAULT_STATUS) && $conf->global->AGENDA_EVENT_DEFAULT_STATUS!=='na') $percent = $conf->global->AGENDA_EVENT_DEFAULT_STATUS;
|
|
||||||
}
|
}
|
||||||
$formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200');
|
$formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|||||||
@ -235,12 +235,11 @@ class DefaultValues extends CommonObject
|
|||||||
* Load object in memory from the database
|
* Load object in memory from the database
|
||||||
*
|
*
|
||||||
* @param int $id Id object
|
* @param int $id Id object
|
||||||
* @param string $ref Ref
|
|
||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetch($id, $ref = null)
|
public function fetch($id)
|
||||||
{
|
{
|
||||||
$result = $this->fetchCommon($id, $ref);
|
$result = $this->fetchCommon($id, null);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,11 +271,13 @@ class DefaultValues extends CommonObject
|
|||||||
$sqlwhere = array();
|
$sqlwhere = array();
|
||||||
if (count($filter) > 0) {
|
if (count($filter) > 0) {
|
||||||
foreach ($filter as $key => $value) {
|
foreach ($filter as $key => $value) {
|
||||||
if ($key == 't.rowid') {
|
if ($key == 't.rowid' || ($key == 't.entity' && !is_array($value)) || $key == 't.user_id') {
|
||||||
$sqlwhere[] = $key.'='.$value;
|
$sqlwhere[] = $key.'='.$value;
|
||||||
} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
|
} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
|
||||||
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
|
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
|
||||||
} elseif ($key == 'customsql') {
|
} elseif ($key == 't.page' || $key == 't.param' || $key == 't.type'){
|
||||||
|
$sqlwhere[] = $key.' = \''.$this->db->escape($value).'\'';
|
||||||
|
} elseif ($key == 'customsql') {
|
||||||
$sqlwhere[] = $value;
|
$sqlwhere[] = $value;
|
||||||
} elseif (is_array($value)) {
|
} elseif (is_array($value)) {
|
||||||
$sqlwhere[] = $key.' IN ('.implode(',',$value).')';
|
$sqlwhere[] = $key.' IN ('.implode(',',$value).')';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user