HTML Code:
function save($check_notify = FALSE){
$GLOBALS['log']->debug("Mahsa: in the save function");
$p_id = $GLOBALS['current_user']->account_id;
$customtype = $this->customtype;
$GLOBALS['log']->debug("Mahsa : customtype".$customtype);
$sex = $this->sex;
$religion = $this->religon;
$status = $this->status ;
$billingdate = $this->billingdate;
$shippingdate = $this->shippingdate;
$phone = $this->phone;
$shippingaddress_city = $this->shippingaddress_city;
$shippingaddress_postalcode = $this->shippingaddress_postalcode;
$shippingaddress_country = $this->shippingaddress_country;
$shippingaddress_subway = $this->shippingaddress_subway;
$shippingaddress_street1 = $this->shippingaddress_street1;
$shippingaddress_street2 = $this->shippingaddress_street2;
$shippingaddress_street3 = $this->shippingaddress_street3;
$shippingaddress_alley = $this->shippingaddress_alley;
$region = $this->region ;
$description = $this->description;
$this->db->query("BEGIN", true , "Error in begining the transaction");
$this->db->query("START TRANSACTION" , true , "Error in starting transaction");
$GLOBALS['log']->debug("Mahsa : account id = ".$GLOBALS['current_user']->account_id);
$query = "SELECT last_invoice_id FROM accounts WHERE id = '18b18262-8e93-6b47-b720-4c1d9e13352b'";
$result = $this->db->query($query,true,"Error in finding invoice id");
$row = $this->db->fetchByAssoc($result);
$last_invoice_id= $row['last_invoice_id'];
$last_invoice_id +=1;
$GLOBALS['log']->debug("Mahsa : last invoice id = ".$last_invoice_id);
$query = "UPDATE accounts SET last_invoice_id = '".$last_invoice_id."' WHERE id = '18b18262-8e93-6b47-b720-4c1d9e13352b'";
$result = $this->db->query($query, true , "Error in updating account table");
$GLOBALS['log']->debug("Mahsa the result of update the table :".$result);
if( $this->db->mysql_error){
$this->db->query("ROLLBACK", true , "Error in Rolling back");
}
else
{
$id = create_guid();
$GLOBALS['log']->debug("Mahsa: else statement before insert query");
$query = "INSERT INTO np_invoicemaster ( id , name , customtype , sex , religion ,status , billingdate ,shippingdate , phone ,
shippingaddress_city , shippingaddress_postalcode , shippingaddress_country , shippingaddress_subway ,
shippingaddress_street1 , shippingaddress_street2 , shippingaddress_street3 ,
shippingaddress_alley , region , description )VALUES( '$id' , '$last_invoice_id', '$customtype' , '$sex' , '$religion' ,
'$status' , '$billingdate' , '$shippingdate' , '$phone' , '$shippingaddress_city' ,
'$shippingaddress_postalcode' , '$shippingaddress_country' , '$shippingaddress_subway' ,
'$shippingaddress_street1' , '$shippingaddress_street2' , '$shippingaddress_street3' ,
'shippingaddress_alley' , '$region' , '$description')";
$result = $this->db->query($query, true ,"Error in inserting data into invoice master table");
$GLOBALS['log']->debug("Mahsa : the result of inserting in invoice master".$result);
$this->db->query("COMMIT" , true);
}
$GLOBALS['log']->debug("Mahsa : the id is =".$id);
return $id;
} So...what should i do?
Bookmarks