Hello there,
I am currently working on a module with a trigger to automatically write computed data to an extrafield. The extrafield in question of the type “date”. I am an admin of the dolibarr, so I don’t understand why it tells me “Access denied.”
Currently I am using a trigger for creation of a supplier bill, to read the data and do the computation. Everything works fine to this point. But when I try either “$db->begin()” or “$this->db->begin()” or “$object->db->begin()” with the trigger and click on the create button the “Access Denied” button shows up. I commented everything out, in parts of sql query and commit/rollback, out so there is only the begin() and the computation of the variables in the code.
The actual promt: “Access denied. You have tried to call a page, area or function that is disabled or has no permission to do so.”
The code:
case 'BILL_SUPPLIER_CREATE':
$object->db->begin();
$id = $object->id;
$ref = $object->ref;
$type = $object->type;
$creationdatestring = $_POST["re"];
$paymentcondition = $_POST["cond_reglement_id"];
setEventMessage("Object Id: ".$id." Ref: ".$ref." Type: ".$type);
//setEventMessage("Object Id: ".$id." Date created: ".$creationdatestring." Payment condition: ".$paymentcondition);
$dateinterval;
if($paymentcondition == "1" || $paymentcondition == "6" || $paymentcondition == "8" || $paymentcondition == "60" || $paymentcondition == "61" || $paymentcondition == "62"){
$dateinterval = new DateInterval("P0D");
}elseif($paymentcondition == "20" || $paymentcondition == "15" || $paymentcondition == "10"){
$dateinterval = new DateInterval("P10D");
}elseif($paymentcondition == "12" || $paymentcondition == "13" || $paymentcondition == "18"){
$dateinterval = new DateInterval("P14D");
}elseif($paymentcondition == "16"){
$dateinterval = new DateInterval("P7D");
}elseif($paymentcondition == "14"){
$dateinterval = new DateInterval("P8D");
}elseif($paymentcondition == "21"){
$dateinterval = new DateInterval("P20D");
}elseif($paymentcondition == "3" || $paymentcondition == "17"){
$dateinterval = new DateInterval("P30D");
}elseif($paymentcondition == "46"){
$dateinterval = new DateInterval("P45D");
}elseif ($paymentcondition == "19" || $paymentcondition == "5"){
$dateinterval = new DateInterval("P60D");
}elseif ($paymentcondition == "59"){
$dateinterval = new DateInterval("P90D");
}else{
$dateinterval = new DateInterval("P1D");
}
$creationdate = date_create_from_format("d.m.Y", $creationdatestring);
$payday = date_add($creationdate, $dateinterval);
$paydaystring = date_format($payday, "d.m.Y");
break;