Exemplo n.º 1
0
    /**
     * Manages all models.
     */
    public function actionAdmin()
    {
        $users = Yii::app()->db->createCommand("SELECT * FROM `tbl_users` WHERE id=" . Yii::app()->user->id);
        $use = $users->queryAll();
        if ($use[0]['superuser'] == 4) {
            echo '<script type="text/javascript">';
            echo 'window.location.href = "http://182.75.35.84/217_php/site/dashboard";';
            echo '</script>';
        } else {
            $model = new Reminders('search');
            $model->unsetAttributes();
            $cur_date = date('m/d/Y');
            //$todays = Reminders::Model()->findallByattributes(array('date'=>$cur_date ));
            /* $comma = Yii::app()->db->createCommand('SELECT tbl_lead_fields.retail,tbl_lead_fields.id,tbl_lead_fields.id, tbl_reminders.msg ,tbl_reminders.date ,tbl_reminders.time ,tbl_lead_fields.email_id,	tbl_lead_fields.first_name,tbl_lead_fields.phone_1 FROM
            		tbl_lead_fields JOIN 
            		tbl_reminders ON tbl_lead_fields.id = tbl_reminders.lead_id and tbl_reminders.date ="'.$cur_date.'" ');	 */
            $comma = Yii::app()->db->createCommand('SELECT 
		a.retail, 
		a.id as leadid,
		c.id,
		a.email_id,
		a.first_name,
		a.phone_1,
		b.msg,
        b.date,
        b.time,
        c.propert_name
			FROM    tbl_lead_fields a
        INNER JOIN tbl_reminders b
            ON a.id = b.lead_id
        INNER JOIN tbl_propery_details c
            ON b.pro_id = c.id
		WHERE   b.date = "' . $cur_date . '" ORDER BY date Desc LIMIT 10');
            $todays = $comma->queryAll();
            /*  echo "<pre>"; print_r($todays); die('ok');   */
            // clear any default values
            if (isset($_GET['Reminders'])) {
                $model->attributes = $_GET['Reminders'];
            }
            $this->render('admin', array('model' => $model, 'today' => $todays));
        }
    }