I'm developing application there i want to generate invoice for various clients,while generating invoice i want to check whether that client has gstin number ,if that client does not have gstin number throw error .up to this i achieved but i want to check client type of that client.If that client type id exist in setting table, gstin should not verify,else verify gstin number for that client.
public function getGstinCType(){
$result = $this->find('all',
array('conditions' =>
array('Setting.row_status' => 0,'Setting.id' => 1),
'fields'=>array('Setting.id','Setting.gstin_C_type'),
)
);
$all_data = array();
foreach ($result as $ind => $row) {
$all_data[$row['Setting']['id']] = $row['Setting']['gstin_C_type'];
}
return $all_data;
}
By above method i am getting array of client type id's like below
out put:
Array
(
[1] => ["38","40","25","4","51"]
)
method in controller to get gstin and client type from client:
public function getGstin($id) {
$gstinCtype = $this->Cases->getClientgstByCaseId($id);
$gstin=$gstinCtype['Client']['gstin'];
$clienttypeId=$gstinCtype['Client']['client_type'];
$ctypeID = $this->Setting->getGstinCType();
if (in_array($ctypeID , $clienttypeId)) {
$gstin = 1;
echo $gstin;
} else {
$gstin = (($gstin == 'null') && !empty($gstin)) ? 0 : 1;
echo $gstin;
exit;
}
}
i want to check with if client type( $clienttypeId) exist in setting table means result of method "getGstinCType()",default value for gstin should take and generate invoice .otherwise throw error to provide gstin number.
thanks in advance any help appriciated.