$production_detail->setRemark($row->{'remarks'});
                 if (!$error) {
                     $production_detail->store();
                 }
             } catch (fExpectedException $e) {
                 echo $e->printMessage();
                 $error = true;
             }
         }
     } catch (fExpectedException $e) {
         echo $e->printMessage();
         $error = true;
     }
 } else {
     if ($_POST['type'] == "removeStock") {
         $records = Inv_stock::gotoStock($_POST['itemCode'], $_POST['branch']);
         if ($records->count()) {
             foreach ($records as $record) {
                 if ($record->getQuantity() < $_POST['itemQuan']) {
                     echo "Item not enough quantity";
                 } else {
                     Inv_stock::removeStock($_POST['itemCode'], $_POST['branch'], $_POST['itemQuan']);
                     $stock = new Production_issue_detail($_POST['detailId']);
                     $stock->setStatus('completed');
                     $stock->store();
                 }
             }
         } else {
             echo "Item not enough quantity.";
         }
     } else {