Ejemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new BugReports();
     $users = User::getNames();
     if (isset($_POST['BugReports'])) {
         $temp = $model->attributes;
         $model->setX2Fields($_POST['BugReports']);
         parent::create($model, $temp, 0);
     }
     $this->render('create', array('model' => $model, 'users' => $users));
 }
Ejemplo n.º 2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Product();
     $users = User::getNames();
     if (isset($_POST['Product'])) {
         $temp = $model->attributes;
         foreach ($_POST['Product'] as $name => &$value) {
             if ($value == $model->getAttributeLabel($name)) {
                 $value = '';
             }
         }
         foreach ($_POST as $key => $arr) {
             $pieces = explode("_", $key);
             if (isset($pieces[0]) && $pieces[0] == 'autoselect') {
                 $newKey = $pieces[1];
                 if (isset($_POST[$newKey . "_id"]) && $_POST[$newKey . "_id"] != "") {
                     $val = $_POST[$newKey . "_id"];
                 } else {
                     $field = Fields::model()->findByAttributes(array('fieldName' => $newKey));
                     if (isset($field)) {
                         $type = ucfirst($field->linkType);
                         if ($type != "Contacts") {
                             eval("\$lookupModel={$type}::model()->findByAttributes(array('name'=>'{$arr}'));");
                         } else {
                             $names = explode(" ", $arr);
                             $lookupModel = Contacts::model()->findByAttributes(array('firstName' => $names[0], 'lastName' => $names[1]));
                         }
                         if (isset($lookupModel)) {
                             $val = $lookupModel->id;
                         } else {
                             $val = $arr;
                         }
                     }
                 }
                 $model->{$newKey} = $val;
             }
         }
         foreach (array_keys($model->attributes) as $field) {
             if (isset($_POST['Product'][$field])) {
                 $model->{$field} = $_POST['Product'][$field];
                 $fieldData = Fields::model()->findByAttributes(array('modelName' => 'Products', 'fieldName' => $field));
                 if ($fieldData->type == 'assignment' && $fieldData->linkType == 'multiple') {
                     $model->{$field} = Accounts::parseUsers($model->{$field});
                 } elseif ($fieldData->type == 'date') {
                     $model->{$field} = strtotime($model->{$field});
                 }
             }
         }
         //               $model->price = $this->parseCurrency($model->price,false);
         $model->createDate = time();
         parent::create($model, $temp, 0);
     }
     $this->render('create', array('model' => $model, 'users' => $users));
 }
Ejemplo n.º 3
0
 public function create($model, $oldAttributes, $api)
 {
     if ($model->associationId == '') {
         $model->associationId = 0;
     }
     //if($model->
     $model->createDate = time();
     // created now, full datetime
     //$model->associationId=$_POST['Actions']['associationId'];
     $dueDate = $this->parseDateTime($model->dueDate);
     $model->dueDate = $dueDate === false ? '' : $dueDate;
     //date('Y-m-d',$dueDate).' 23:59:59';	// default to being due by 11:59 PM
     //if($type=='none')
     //	$model->associationId=0;
     //$model->associationType=$type;
     $association = $this->getAssociation($model->associationType, $model->associationId);
     if ($association != null) {
         $model->associationName = $association->name;
     } else {
         $model->associationName = 'None';
         //$model->associationId = 0;
     }
     if ($model->associationName == 'None' && $model->associationType != 'none') {
         $model->associationName = ucfirst($model->associationType);
     }
     //		$this->render('test', array('model'=>$model));
     if ($model->type != 'event' && isset($_POST['submit']) && ($_POST['submit'] == '0' || $_POST['submit'] == '2')) {
         // if user clicked "New Comment" rather than "New Action"
         $model->createDate = time();
         $model->dueDate = time();
         $model->completeDate = time();
         $model->complete = 'Yes';
         $model->visibility = '1';
         $model->assignedTo = Yii::app()->user->getName();
         $model->completedBy = Yii::app()->user->getName();
         $model->type = $_POST['submit'] == 2 ? 'note' : 'call';
     } else {
         if ($model->type == 'event') {
             if ($model->completeDate) {
                 $model->completeDate = $this->parseDateTime($model->completeDate);
             }
         }
     }
     if (!is_numeric($model->assignedTo)) {
         // assigned to user
         $profile = ProfileChild::model()->findByAttributes(array('username' => $model->assignedTo));
         $profile->syncActionToGoogleCalendar($model);
         // sync action to Google Calendar if user has a Google Calendar
     }
     if ($api == 0) {
         parent::create($model, $oldAttributes, $api);
     } else {
         return parent::create($model, $oldAttributes, $api);
     }
 }
Ejemplo n.º 4
0
 public function create($model, $oldAttributes, $api = 0)
 {
     // process currency into an INT
     //		$model->quoteAmount = $this->parseCurrency($model->quoteAmount,false);
     if (isset($model->associatedContacts)) {
         $model->associatedContacts = Sales::parseContacts($model->associatedContacts);
     }
     $model->createDate = time();
     $model->lastUpdated = time();
     // $model->expectedCloseDate = $this->parseDate($model->expectedCloseDate);
     parent::create($model, $oldAttributes, '0');
 }
Ejemplo n.º 5
0
 public function create($model, $oldAttributes, $api)
 {
     if ($api == 0) {
         parent::create($model, $oldAttributes, $api);
     } else {
         return parent::create($model, $oldAttributes, $api);
     }
 }
Ejemplo n.º 6
0
 /**
  * Creates opportunity record
  *
  * Call this function from createRecords
  */
 public function createOpportunity($model, $oldAttributes, $api = 0)
 {
     // process currency into an INT
     //        $model->quoteAmount = Formatter::parseCurrency($model->quoteAmount,false);
     if (isset($model->associatedContacts)) {
         $model->associatedContacts = Opportunity::parseContacts($model->associatedContacts);
     }
     $model->createDate = time();
     $model->lastUpdated = time();
     // $model->expectedCloseDate = Formatter::parseDate($model->expectedCloseDate);
     if ($api == 1) {
         return parent::create($model, $oldAttributes, $api);
     } else {
         parent::create($model, $oldAttributes, '0');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new MarketingChild();
     $name = 'MarketingChild';
     parent::create($model, $name);
 }
Ejemplo n.º 8
0
 public function create($model, $oldAttributes, $api)
 {
     /* if($model->associationId=='')
               $model->associationId=0;
               //if($model->
     
               $model->createDate = time();	// created now, full datetime
               //$model->associationId=$_POST['Actions']['associationId'];
               if(!is_numeric($model->dueDate)){
               $dueDate = Formatter::parseDateTime($model->dueDate);
               $model->dueDate = ($dueDate===false)? '' : $dueDate; //date('Y-m-d',$dueDate).' 23:59:59';	// default to being due by 11:59 PM
               } */
     //if($type=='none')
     //	$model->associationId=0;
     //$model->associationType=$type;
     /* $association = $this->getAssociation($model->associationType,$model->associationId);
     
               if($association != null) {
               $model->associationName = $association->name;
               if($association->hasAttribute('lastActivity') && $api==0) {
               $association->lastActivity = time();
               $association->update(array('lastActivity'));
               }
               } else {
               $model->associationName='None';
               //$model->associationId = 0;
               }
               if($model->associationName=='None' && $model->associationType!='none'){
               $model->associationName=ucfirst($model->associationType);
               } */
     //		$this->render('test', array('model'=>$model));
     /* if($model->type != 'event' && isset($_POST['submit']) && ($_POST['submit']=='0' || $_POST['submit']=='2') && $model->calendarId == null) {	// if user clicked "New Comment" rather than "New Action"
        $model->createDate = time();
        $model->dueDate = time();
        $model->completeDate = time();
        $model->complete='Yes';
        $model->visibility='1';
        $model->assignedTo=Yii::app()->user->getName();
        $model->completedBy=Yii::app()->user->getName();
        $model->type=$_POST['submit']==2?'note':'call';
        } else if($model->type == 'event') {
        if($model->completeDate) {
        $model->completeDate = Formatter::parseDateTime($model->completeDate);
        }
        } */
     // $model->syncGoogleCalendar();
     // google sync
     /* if(!is_numeric($model->assignedTo)) { // assigned to user
        $profile = Profile::model()->findByAttributes(array('username'=>$model->assignedTo));
        if(isset($profile))
        $profile->syncActionToGoogleCalendar($model); // sync action to Google Calendar if user has a Google Calendar
        } else { // Assigned to group
        $groups = Yii::app()->db->createCommand()->select('userId')->from('x2_group_to_user')->where("groupId={$model->assignedTo}")->queryAll();
        foreach($groups as $group) {
        $profile = Profile::model()->findByPk($group['userId']);
        if(isset($profile))
        $profile->syncActionToGoogleCalendar($model);
        }
        } */
     if ($api == 0) {
         parent::create($model, $oldAttributes, $api);
     } else {
         return parent::create($model, $oldAttributes, $api);
     }
 }
Ejemplo n.º 9
0
 public function create($model, $oldAttributes, $api)
 {
     $model->createDate = time();
     $model->lastUpdated = time();
     if ($api == 0) {
         parent::create($model, $oldAttributes, $api);
     } else {
         $lookupFields = Fields::model()->findAllByAttributes(array('modelName' => 'Contacts', 'type' => 'link'));
         foreach ($lookupFields as $field) {
             $fieldName = $field->fieldName;
             if (isset($model->{$fieldName})) {
                 $lookup = CActiveRecord::model(ucfirst($field->linkType))->findByAttributes(array('name' => $model->{$fieldName}));
                 if (isset($lookup)) {
                     $model->{$fieldName} = $lookup->id;
                 }
             }
         }
         return parent::create($model, $oldAttributes, $api);
     }
 }
Ejemplo n.º 10
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function create($model, $oldAttributes, $api)
 {
     $model->annualRevenue = $this->parseCurrency($model->annualRevenue, false);
     $model->createDate = time();
     if ($api == 0) {
         parent::create($model, $oldAttributes, $api);
     } else {
         return parent::create($model, $oldAttributes, $api);
     }
 }
Ejemplo n.º 11
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Campaign();
     if (isset($_POST['Campaign'])) {
         $oldAttributes = $model->attributes;
         $model->setX2Fields($_POST['Campaign']);
         parent::create($model, $oldAttributes, 0);
     }
     $this->render('create', array('model' => $model));
 }