<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Trippest
{
    protected $ci;

    public function __construct()
    {
        $this->ci =& get_instance();
    }

    public function tour_name($pag_code)
    {
        $name = "";
        switch ($pag_code) {
            case 'BJSIC-41':
                $name = "One Day Beijing Highlights Tour";
                break;
            case 'BJSIC-42':
                $name = "Two-Day Beijing Boutique Small Group Tour";
                break;
            case 'BJSIC-43':
                $name = "Three-Day Beijing Discovery Tour";
                break;

            default:
                break;
        }
        return $name;
    }

    public $special_route = array(
        "BJSIC-42" => array(
            "code" => array('BJSIC-41','BJSIC-42')
            ,"name" => "北京精品两日游（目的地BJSIC-42）"
            ,"day" => 2
         )
        ,"BJSIC-43" => array(
            "code" => array('BJSIC-41','BJSIC-42','BJSIC-43')
            ,"name" => "北京精品三日游（目的地BJSIC-43）"
            ,"day" => 3
         )
        ,"XASIC-42" => array(
            "code" => array('XASIC-41','XASIC-42')
            ,"name" => "西安精品两日游（目的地XASIC-42）"
            ,"day" => 2
         )
    );
    public function tour_code($pag_code)
    {
        $ret = array($pag_code);
        if (isset($this->special_route[$pag_code])) {
            $ret = $this->special_route[$pag_code]["code"];
        }
        return $ret;
    }

    public function ch_code_transfer($code)
    {
        $trippest_code = $code;
        switch ($code) {
            case 'SHALC-6':
            case 'SHALC-7':
            case 'SHALC-8':
            case 'SHALC-9':
                $trippest_code = "SHSIC-45";
                break;
            case 'SHSIC-31':
                $trippest_code = "SHSIC-41";
                break;
            case 'SHSIC-32':
                $trippest_code = "SHSIC-42";
                break;
            case 'SHSIC-33':
                $trippest_code = "SHSIC-43";
                break;

            default:
                break;
        }
        return $trippest_code;
    }

    /*!
     * @Author: LYT
     * @Date: 2019-05-28 15:17:11
     * @Desc: 判断产品是否需要发送PVT计划
     * @param $all_pag_info = array((pag.*),(pag.*))
     * @return 1-pvt;2-combine
     */
    public function if_tour_pvt($all_pag_info)
    {
        $tour_pvt_arr = array_filter(array_map(function($pag) {
            // 扩展类型:接送
            // 交通:非-[大车]
            if(intval($pag->PAG_ExtendType)===39009
                && ! in_array(intval($pag->PAG_Vehicle), array(60002)))
            {
                return 1;
            } else if (stripos($pag->PAG_Title,"PVT") !== false) {
                return 1;
            } else if (stripos($pag->PAG_Title,"private") !== false) {
                return 1;
            } else {
                return null;
            }
        }, $all_pag_info));
        $order_type = empty($tour_pvt_arr) ? 2 : 1;
        return $order_type;
    }



}

/* End of file trippest.php */
/* Location: ./third_party/vendorPlanSync/libraries/trippest.php */
