dougan1205 2019-04-12 07:13
浏览 13

如何获取数组值并与cakePHP服务中的其他变量进行比较?

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?