if (isset($_POST['item_id']) and !empty($_POST['item_id']) and isset($_POST['item_name']) and !empty($_POST['item_name']) and isset($_POST['item_code']) and !empty($_POST['item_code']) and isset($_POST['mrp']) and isset($_POST['tax_category_id']) and !empty($_POST['tax_category_id']) and isset($_POST['purchace_rate']) and isset($_POST['discount_percent']) and isset($_POST['unit']) and !empty($_POST['unit'])) {
         $item = new item();
         $item->id = $_POST['item_id'];
         $item->getItem();
         $item->item_code = $_POST['item_code'];
         $item->item_name = $_POST['item_name'];
         $item->mrp = $_POST['mrp'];
         $item->purchace_rate = $_POST['purchace_rate'];
         $item->tax_category_id = $_POST['tax_category_id'];
         $item->discount_percent = $_POST['discount_percent'];
         $item->unit = $_POST['unit'];
         if ($item->updateItem()) {
             $message = "Item Updated Successfuly";
             $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $item->id));
         } else {
             $description = "Item update failed, item : " . $item->to_string();
             Log::e($tag, $description);
             $mysql_error = mysql_error();
             if (empty($mysql_error)) {
                 $error_message = 'Some server error occured';
             } else {
                 $error_message = $mysql_error;
             }
             $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array());
         }
     } else {
         $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
     }
 } else {
     if ($form_id == 22) {
         ///edit bank
 } else {
     if ($form_id == 11) {
         //item form
         if (isset($_POST['item_code']) and !empty($_POST['item_code']) and isset($_POST['item_name']) and !empty($_POST['item_name']) and isset($_POST['mrp']) and isset($_POST['tax_category_id']) and !empty($_POST['tax_category_id']) and isset($_POST['purchace_rate']) and isset($_POST['discount_percent']) and isset($_POST['unit']) and !empty($_POST['unit'])) {
             $item = new item();
             $item->item_code = $_POST['item_code'];
             $item->item_name = $_POST['item_name'];
             $item->mrp = $_POST['mrp'];
             $item->tax_category_id = $_POST['tax_category_id'];
             $item->purchace_rate = $_POST['purchace_rate'];
             $item->discount_percent = $_POST['discount_percent'];
             $item->unit = $_POST['unit'];
             if ($item->addItem()) {
                 $responce = array('status' => 'success', 'error' => '', 'data' => array('message' => 'Item Added successfully'));
             } else {
                 Log::e($tag, "Item adding failed item : " . $item->to_string() . 'Error : ' . mysql_error());
                 $mysql_error = mysql_error();
                 if (empty($mysql_error)) {
                     $error_message = 'Some server error occured';
                 } else {
                     $error_message = $mysql_error;
                 }
                 $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array());
             }
         } else {
             $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
         }
     } else {
         if ($form_id == 22) {
             //bank form
             if (isset($_POST['bank_name']) and !empty($_POST['bank_name']) and isset($_POST['branch']) and !empty($_POST['branch']) and isset($_POST['ifsc_code']) and !empty($_POST['ifsc_code']) and isset($_POST['account_number']) and !empty($_POST['account_number'])) {
});
session_start();
if (isset($_SESSION['user_id']) and !empty($_SESSION['user_id']) and isset($_GET['user_id']) and !empty($_GET['user_id']) and $_SESSION['user_id'] === $_GET['user_id']) {
    if (isset($_POST['form_id']) and !empty($_POST['form_id'])) {
        $form_id = $_POST['form_id'];
        $tag = "DELETE_FORM_DATA";
        if ($form_id == 17) {
            ///item delete
            if (isset($_POST['item_id']) and !empty($_POST['item_id'])) {
                $item = new item();
                $item->id = $_POST['item_id'];
                if ($item->deleteItem()) {
                    $message = "Item deleted Successfuly";
                    $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $item->id));
                } else {
                    $description = "Item delete failed, item : " . $item->to_string();
                    Log::e($tag, $description);
                    $mysql_error = mysql_error();
                    if (empty($mysql_error)) {
                        $error_message = 'Some server error occured';
                    } else {
                        $error_message = $mysql_error;
                    }
                    $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array());
                }
            } else {
                $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
            }
        } else {
            if ($form_id == 18) {
                ///vendor delete