<?php
$cs = Yii::app()->getClientScript();

$baseUrl = Yii::app()->baseUrl;

$livesite = Yii::app()->getBaseUrl(true) . "/";
?>

<?php
$modelCompanySettings = new MasCompanySettings();
$modelCompanySettings = $modelCompanySettings->find(array('condition'=>'crm_company_id='.(int) Yii::app()->user->master_user_company_id));    

$current_url = Yii::app()->urlManager->parseUrl(Yii::app()->request);
$sales = '';

  switch ($current_url) {
        //SALES MENU

        case 'customer/index':

            $sales = 'active';

            break;

        case 'lead/index':

            $sales = 'active';
            
            break;

        case 'quotation/index':

            $sales = 'active';
            break;

        case 'order/index':

            $sales = 'active';
            break;

        case 'order/deliverytracker':

            $sales = 'active';

            break;

        case 'order/paymenttracker':

            $sales = 'active';

            break;

        case 'delivery/index':

            $sales = 'active';

            break;

        case 'invoice/index':

            $sales = 'active';

            break;

        case 'creditnote/index':

            $sales = 'active';

            break;

        case 'directorder/index':

            $sales = 'active';

            break;

        case 'directinvoice/index':

            $sales = 'active';

            break;

        case 'packaging/index':

            $sales = 'active';

            break;
  }

?>
 <!---------------------------------------     Start sales li ----------------------------------------->
  <?php if ($modelCompanySettings->sales_menu==1) {?>
    
    <li id="sales" <?php echo "class='$sales has-sub l2'"; ?> style="display: none;">

        <a href="<?php echo 'index.php?r=customer/index';?>" data-target="#sales_menu">

            <i class="fa fa-line-chart"></i>

            <span>Sales</span>

        </a>

        <ul class="menu-2-sub" id="sales_menu">


                <?php if (isset(Yii::app()->user->havePermissionOn['customer_view']) || Yii::app()->user->authorised_user == 1) {
                    ?>

                    <li><a href="<?php echo $baseUrl; ?>/index.php?r=customer/index"><i class="fa fa-users"></i> Customers</a></li>

                    <?php
                }
            ?>

                <li>

                    <a href="javascript:void(0);"><i class="fa fa-cogs"></i> Operations</a>

                    <ul>

                        <?php  if (Yii::app()->user->authorised_user == 1 || ((int) Yii::app()->user->havePermissionOn["lead_view"])) {?>

                        <!-- <li><a href="<?php echo $baseUrl; ?>/index.php?r=lead/index"><i class="fa fa-line-chart"></i> Leads</a></li> -->

                        <?php
                        }
                        ?>

                        <?php
                        if (Yii::app()->user->authorised_user == 1 || ((int) Yii::app()->user->havePermissionOn["quotes_view"])) {
                            ?>

                            <!-- <li  ><a href="<?php echo $baseUrl; ?>/index.php?r=quotation/index"><i class="material-icons">assignment</i> Quotations</a></li> -->

                            <?php
                        }
                        ?>

                        <?php

                            if (Yii::app()->user->authorised_user == 1 || ((int) Yii::app()->user->havePermissionOn["order_view"])) {
                                ?>

                                <li  ><a href="<?php echo $baseUrl; ?>/index.php?r=order/index"><i class="material-icons">description</i> Orders</a></li>

                                <?php
                            }
                        ?>

                        <?php
                            if (Yii::app()->user->authorised_user == 1 || ((int) Yii::app()->user->havePermissionOn["delivery_view"])) {
                        ?>

                                    <!-- <li  ><a href="<?php echo $baseUrl; ?>/index.php?r=delivery/index"><i class="material-icons">description</i> Delivery Note</a></li>                                                                                                                                                                                                                                                                                                                                                 <li><a href="<?php echo $baseUrl; ?>/index.php?r=delivery/index"><i class="material-icons">description</i> Delivery Note</a></li> -->

                        <?php
                            }
                        ?>


                        <?php

                            if (Yii::app()->user->authorised_user == 1 || ((int) Yii::app()->user->havePermissionOn["invoice_view"])) {
                                ?>

                                <li><a href="<?php echo $baseUrl; ?>/index.php?r=invoice/index"><i class="fa fa-file-text-o"></i> Invoice</a></li>

                                <?php
                            }
                        ?>

                        <?php

                        if (Yii::app()->user->authorised_user == 1 || ((int) Yii::app()->user->havePermissionOn["credit_view"])) {
                            ?>

                            <!-- <li ><a href="<?php echo $baseUrl; ?>/index.php?r=creditnote/index"><i class="fa fa-money"></i> Sales Return</a></li> -->

                            <?php
                        }
                        ?>
                            <!-- <li><a href="<?php echo $baseUrl; ?>/index.php?r=directinvoice/index"><i class="fa fa-balance-scale"></i> Pre Invoice</a></li> -->

                        <?php
                        /* if (isset(Yii::app()->user->havePermissionOn['direct_sales_view']) || Yii::app()->user->authorised_user == 1) {

                            ?>

                            <li><a class="bg-success" href="<?php echo $baseUrl; ?>/index.php?r=directinvoice/index"><i class="fa fa-balance-scale"></i> Direct Sales</a></li>

                            <?php

                            } */
                        ?>

                    </ul>

                </li>

           
        


        </ul>
    </li> 
    <?php
}
?>

 <!---------------------------------------     end sales li ----------------------------------------------->
 