$mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")) . '</div>'; $action = 'create'; } elseif (!$_POST["actioncode"] > 0) { $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")) . '</div>'; $action = 'create'; } elseif (!$_POST["amount"]) { $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")) . '</div>'; $action = 'create'; } else { $chargesociales = new ChargeSociales($db); $chargesociales->type = $_POST["actioncode"]; $chargesociales->lib = $_POST["label"]; $chargesociales->date_ech = $dateech; $chargesociales->periode = $dateperiod; $chargesociales->amount = $_POST["amount"]; $id = $chargesociales->create($user); if ($id > 0) { //$mesg='<div class="ok">'.$langs->trans("SocialContributionAdded").'</div>'; } else { $mesg = '<div class="error">' . $chargesociales->error . '</div>'; } } } if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer) { $dateech = dol_mktime($_POST["echhour"], $_POST["echmin"], $_POST["echsec"], $_POST["echmonth"], $_POST["echday"], $_POST["echyear"]); $dateperiod = dol_mktime($_POST["periodhour"], $_POST["periodmin"], $_POST["periodsec"], $_POST["periodmonth"], $_POST["periodday"], $_POST["periodyear"]); if (!$dateech) { $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")) . '</div>'; $action = 'edit'; } elseif (!$dateperiod) { $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")) . '</div>';
/** * testChargeSocialesCreate * * @return void */ public function testChargeSocialesCreate() { global $conf,$user,$langs,$db; $conf=$this->savconf; $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; $localobject=new ChargeSociales($this->savdb); $localobject->initAsSpecimen(); $result=$localobject->create($user,$langs,$conf); print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); return $result; }
$action = ''; } if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->tax->charges->creer) { $db->begin(); $originalId = $id; $object = new ChargeSociales($db); $object->fetch($id); if ($object->id > 0) { $object->paye = 0; $object->id = $object->ref = null; if (GETPOST('clone_for_next_month') != '') { $object->date_ech = strtotime('+1month', $object->date_ech); $object->periode = strtotime('+1month', $object->periode); } if ($object->check()) { $id = $object->create($user); if ($id > 0) { $db->commit(); $db->close(); header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit; } else { $id = $originalId; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } } else { $db->rollback(); dol_print_error($db, $object->error); }
function create_charge_sociale($id_source, $date) { global $user; // Récupération de la charge sociale initiale $obj = new ChargeSociales($this->db); $obj->fetch($id_source); if (empty($obj->id)) { return false; } else { // Création de la nouvelle charge sociale $chargesociale = new ChargeSociales($this->db); $chargesociale->type = $obj->type; $chargesociale->lib = $obj->lib; $chargesociale->date_ech = $date; $chargesociale->periode = $date; $chargesociale->amount = $obj->amount; $id = $chargesociale->create($user); $chargesociale->add_object_linked('chargesociales', $id_source); return $id; } }