<modification>
    <id>Velocity Menubar v1.0 By Velocity</id>
    <version>1.5.x</version>
    <vqmver>2.2.1</vqmver>
    <author>Nitin Jain</author>
    <file name="admin/view/template/common/header.tpl">
        <operation>
            <search position="before"><![CDATA[<li id="help"><a class="top"><?php echo $text_help; ?></a>]]></search>
            <add><![CDATA[
<?php if($show_menubar == 1) { ?>
        <style type='text/css'>
        #velocity_menubar ul {
            min-height: 225px;
        }
        </style>
        <li id="velocity_menubar"><a class="top"><?php  echo 'Velocity Plugins'; if($show_notification==1) echo'<div style="float:right;padding-top:-6px !important;"><img hspace="5" height=20px width=20px src="view/image/add_notification.png"></div>' ; ?></a>
         <ul>
          <div style="color:white;  height:100px;">

            <?php
                 $count=0;
                 foreach($plugin_name as $plugin) { ?>
                 <?php if($install_status[$count]==1) { ?>
                 <li style="font-family: 'Helvetica Neue','Helvetica','Arial',sans-serif;" ><a href="<?php echo $this->url->link($edit_plugin[$count], 'token=' . $this->session->data['token'], 'SSL'); ?>"><?php echo $plugin_name[$count];  ?></a></li>
            <?php } $count++; } ?>


    <?php if($show_add_content != "" ){ ?>
        <div style="
background-color:#B3673C ;
font-family: 'Helvetica Neue','Helvetica','Arial',sans-serif;
height:99.1%;
right: -350px;
position: absolute;
box-shadow: 1px 0 0 0 #FFFFFF inset, -8px 0 8px -5px rgba(0, 0, 0, 0.1) inset, 8px 0 8px -5px rgba(0, 0, 0, 0.1) inset;
top: 0.5px;
width: 350px;
z-index: 89999;
-webkit-transition: all 1.0s ease-in-out;
-moz-transition: all 1.0s ease-in-out;
-o-transition: all 1.0s ease-in-out;
transition: all 1.0s ease-in-out;
">
            <div>
				<div style='padding:10px;'>
						<?php echo $show_add_content; ?>
				</div>
            </div>
        </div>
        <?php } ?>
     </div>
        </ul>
      </li>
<?php } ?>
            ]]></add>
        </operation>

        <operation>
            <search position="before"><![CDATA[</head>]]></search>
            <add><![CDATA[
            <script type="text/javascript">
                jQuery(document).ready(function() {
                    $('#velocity_menubar').hover(function() {
                        var token="<?php echo $this->session->data['token']; ?>";
                           $.ajax({
                            url: 'index.php?route=common/home/update_addflag&token='+token,
                            success: function(json) {
                        }
                    });
                }, function() {
                        $('#show_details').html('');
                    });
                });
            </script>
            ]]></add>
        </operation>
    </file>
    <file name="admin/controller/common/header.php">
        <operation>
            <search position="after"><![CDATA[protected function index() {]]></search>
            <add><![CDATA[
            $count = 0;
            $this->data['show_menubar'] = 0;
            $this->load->model('setting/setting');
            $notification=$this->model_setting_setting->getSetting('notification');
            if(isset($notification['flag_add'])) {
            } else {
                $notification['flag_add'] = 0;
                $this->model_setting_setting->editSetting('notification',$notification);
            }
            $old_settings=$this->model_setting_setting->getSetting('velocity_menubar');
            foreach($old_settings as $old) {
                if($old[0] == 1) {
                    $this->data['show_menubar'] = 1;
                }
                $this->data['install_status'][$count] = $old[0];
                $this->data['plugin_name'][$count] = $old[1];
                $this->data['edit_plugin'][$count] = $old[2];
                $count++;
            }

            $this->data['show_add_content'] = "";
            $this->data['show_notification'] = 0;
            $this->data['adv_id'] = 0;
            $this->data['plugin_id'] = '0C0000';
            $result_add = $this->getAdd($this->data['adv_id'],$this->data['plugin_id']);
            if($result_add['flag']) {
                $this->load->model('setting/setting');
                $notification=$this->model_setting_setting->getSetting('notification');
                if($notification['flag_add']!=$result_add['flag']) {
                    $this->data['show_notification'] = 1;
                } else {
                    $this->data['show_notification'] = 0;
                }
                $this->data['adv_id'] = $result_add['adv_id'];
                $this->data['show_add_content'] = $result_add['content'];
                $this->data['flag_add'] = $result_add['flag'];
            } else {
                $this->data['adv_id'] = $result_add['adv_id'];
                $this->data['show_add_content'] = $result_add['content'];
                $this->data['flag_add'] = 0;
            }
            ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[protected function index() {]]></search>
            <add><![CDATA[
            public function getAdd($adv_id, $plugin_id) {
                $data = array('adv_id' => $adv_id, 'plugin_id' => $plugin_id);
                $ch = curl_init('http://ocdemo.velsof.com/velsof_advertisement.php');
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $data )."&type=front&url=".HTTP_SERVER);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,5);
                curl_setopt($ch, CURLOPT_TIMEOUT, 5); //timeout in seconds
                $response = curl_exec($ch);
                curl_close($ch);
                if($response) {
                    $response_decode = (array)json_decode($response);
                    if(!empty($response_decode)) {
                        return $response_decode;
                    }
                }
            }
            ]]></add>
        </operation>
    </file>

    <file name="admin/controller/common/home.php">
        <operation>
            <search position="before"><![CDATA[public function index() {]]></search>
            <add><![CDATA[
            public function update_addflag() {
                $this->data['adv_id'] = 0;
                $this->data['plugin_id'] = '0C0001';
                $this->load->model('setting/setting');
                $notification=$this->model_setting_setting->getSetting('notification');
                $result_add = $this->getAdd($this->data['adv_id'],$this->data['plugin_id']);
                if($result_add['flag']&&$notification['flag_add']!=$result_add['flag']) {
                    $notification['flag_add']=$result_add['flag'];
                    $this->model_setting_setting->editSetting('notification',$notification);
                }
            }

            public function getAdd($adv_id, $plugin_id) {
                $data = array('adv_id' => $adv_id, 'plugin_id' => $plugin_id);
                $ch = curl_init('http://ocdemo.velsof.com/velsof_advertisement.php');
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $data )."&type=front&url=".HTTP_SERVER);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                curl_close($ch);
                if($response) {
                    $response_decode = (array)json_decode($response);
                    if(!empty($response_decode)) {
                        return $response_decode;
                    }
                }
            }
                ]]></add>
        </operation>
    </file>
</modification>