Need some help here please.I have a table that has multiple different fields :
CREATE TABLE `comp_link` (
`pk` int(11) NOT NULL,
`comp_name` varchar(255) DEFAULT NULL,
`email_add` varchar(255) DEFAULT NULL,
`notes` longtext DEFAULT NULL,
`mod_fica` int(1) DEFAULT 2,
`mod_job` int(1) DEFAULT 2,
`mod_note` int(1) DEFAULT 2,
`mod_deadfile` int(1) DEFAULT 2,
`mod_sars_calendar` int(1) DEFAULT NULL,
`mod_x1` int(1) DEFAULT NULL,
`mod_x2` int(1) DEFAULT NULL,
`mod_x3` int(1) DEFAULT NULL,
`mod_x4` int(1) DEFAULT NULL,
`mod_x5` int(1) DEFAULT NULL,
`auth_person` varchar(900) DEFAULT NULL,
`auth_contact1` varchar(900) DEFAULT NULL,
`auth_contact2` varchar(900) DEFAULT NULL,
`bill_contact_name` varchar(900) DEFAULT NULL,
`bill_contact_email` varchar(900) DEFAULT NULL,
`bill_contact_number` varchar(900) DEFAULT NULL,
`billing_add_1` varchar(900) DEFAULT NULL,
`billing_add_2` varchar(900) DEFAULT NULL,
`billing_add_3` varchar(900) DEFAULT NULL,
`billing_add_4` varchar(900) DEFAULT NULL,
`billing_add_5` varchar(900) DEFAULT NULL,
`billing_add_6` varchar(900) DEFAULT NULL,
`contract` varchar(255) DEFAULT NULL,
`contract_expiry` date DEFAULT NULL,
`bank_letter` varchar(45) DEFAULT NULL,
`bill_type` int(2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
i am trying to have files uploaded (with a changed name) into contract. I have got the code to work but the problem is when the file is not uploaded or other items change.Here is my code:
public function rowUpdating(array $oldRow, array &$newRow): ?bool
{
// Enter your code here
// To cancel, set return value to false
// To skip for grid insert/update, set return value to null
if ($newRow["contract"] != "") {
}
elseif ($newRow["contract"] == $oldRow["contract"]) {
}
elseif ($newRow["contract"] != $oldRow["contract"]) {
$files = $newRow["contract"];
$zz1 = CurrentDate();
$zz2 = '.';
$zz3 = mt_rand(1111111111,9999999999);
$file_extension = substr(strtolower(strrchr($files, ".")), 1);
$zz4 = $zz1.$zz2.$zz3.".".$file_extension ;
$newRow["contract"] = "$zz4" ;
}
return true;
}
In the debug i am getting the following:
Warning
C:\xampp\htdocs\backoffice1\models\CompLink.php(3044): Undefined array key "contract"
the line in question here is :
if ($newRow["contract"] != "") {
Any assistance or nudge in the right direction would be really gratefull.