Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • CreateWebFormAction
  • GetActionsBetweenAction
  • MobileAction
  • MobileActivityAction
  • MobileCreateAction
  • MobileDeleteAction
  • MobileIndexAction
  • MobileProfileViewAction
  • MobilePublisherAction
  • MobileResetPasswordAction
  • MobileTopicsCreateAction
  • MobileTopicsDeleteReplyAction
  • MobileTopicsIndexAction
  • MobileTopicsUpdateAction
  • MobileTopicsUpdateReplyAction
  • MobileTopicsViewAction
  • MobileUpdateAction
  • MobileViewAction
  • MobileViewEventAction
  • RecordAliasesCreateAction
  • RecordAliasesDeleteAction
  • WebFormAction
  • X2GridViewMassActionAction
  • X2ModelConversionAction
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /*****************************************************************************************
  3:  * X2Engine Open Source Edition is a customer relationship management program developed by
  4:  * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  5:  * 
  6:  * This program is free software; you can redistribute it and/or modify it under
  7:  * the terms of the GNU Affero General Public License version 3 as published by the
  8:  * Free Software Foundation with the addition of the following permission added
  9:  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 10:  * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
 11:  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 12:  * 
 13:  * This program is distributed in the hope that it will be useful, but WITHOUT
 14:  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 15:  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 16:  * details.
 17:  * 
 18:  * You should have received a copy of the GNU Affero General Public License along with
 19:  * this program; if not, see http://www.gnu.org/licenses or write to the Free
 20:  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 21:  * 02110-1301 USA.
 22:  * 
 23:  * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 24:  * California 95067, USA. or at email address contact@x2engine.com.
 25:  * 
 26:  * The interactive user interfaces in modified source and object code versions
 27:  * of this program must display Appropriate Legal Notices, as required under
 28:  * Section 5 of the GNU Affero General Public License version 3.
 29:  * 
 30:  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 31:  * these Appropriate Legal Notices must retain the display of the "Powered by
 32:  * X2Engine" logo. If the display of the logo is not reasonably feasible for
 33:  * technical reasons, the Appropriate Legal Notices must display the words
 34:  * "Powered by X2Engine".
 35:  *****************************************************************************************/
 36: 
 37: 
 38: class WebFormAction extends CAction {
 39: 
 40:     public static function sanitizeGetParams () {
 41:         //sanitize get params
 42:         $whitelist = array(
 43:             'fg', 'bgc', 'font', 'bs', 'bc', 'iframeHeight'
 44:         );
 45:         $_GET = array_intersect_key($_GET, array_flip($whitelist));
 46:         //restrict param values, alphanumeric, # for color vals, comma for tag list, . for decimals
 47:         $_GET = preg_replace('/[^a-zA-Z0-9#,.]/', '', $_GET);
 48:         return $_GET;
 49:     }
 50: 
 51:     private static function addTags ($model) {
 52:         // add tags
 53:         if(!empty($_POST['tags'])){
 54:             $taglist = explode(',', $_POST['tags']);
 55:             if($taglist !== false){
 56:                 foreach($taglist as &$tag){
 57:                     if($tag === '')
 58:                         continue;
 59:                     if(substr($tag, 0, 1) != '#')
 60:                         $tag = '#'.$tag;
 61:                     $tagModel = new Tags;
 62:                     $tagModel->taggedBy = 'API';
 63:                     $tagModel->timestamp = time();
 64:                     $tagModel->type = get_class ($model);
 65:                     $tagModel->itemId = $model->id;
 66:                     $tagModel->tag = $tag;
 67:                     $tagModel->itemName = $model->name;
 68:                     $tagModel->save();
 69: 
 70:                     X2Flow::trigger('RecordTagAddTrigger', array(
 71:                         'model' => $model,
 72:                         'tags' => $tag,
 73:                     ));
 74:                 }
 75:             }
 76:         }
 77:     }
 78: 
 79:     
 80: 
 81:     
 82: 
 83:     private function handleWebleadFormSubmission (X2Model $model, $extractedParams) {
 84:         $newRecord = $model->isNewRecord;
 85:         if(isset($_POST['Contacts'])) {
 86: 
 87:             $model->createEvent = false;
 88:             $model->setX2Fields($_POST['Contacts'], true);
 89:             // Extra sanitizing
 90:             $p = Fields::getPurifier();
 91:             foreach($model->attributes as $name=>$value) {
 92:                 if($name != $model->primaryKey() && !empty($value)) {
 93:                     $model->$name = $p->purify($value);
 94:                 }
 95:             }
 96:             $now = time();
 97: 
 98:             
 99:             $model->visibility = 1;
100: 
101:             $model->validate (null, false);
102:             if(!$model->hasErrors()){
103:                 $model->lastUpdated = $now;
104:                 $model->updatedBy = 'admin';
105: 
106:                 
107:                 
108:                 if($model->asa('X2DuplicateBehavior') && $model->checkForDuplicates()){
109:                     $duplicates = $model->getDuplicates();
110:                     $oldest = $duplicates[0];
111:                     $fields = $model->getFields(true);
112:                     foreach ($fields as $field) {
113:                         if (!in_array($field->fieldName,
114:                                         $model->X2MergeableBehavior->restrictedFields)
115:                                 && !is_null($model->{$field->fieldName})) {
116:                             if ($field->type === 'text' && !empty($oldest->{$field->fieldName})) {
117:                                 $oldest->{$field->fieldName} .= "\n--\n" . $model->{$field->fieldName};
118:                             } else {
119:                                 $oldest->{$field->fieldName} = $model->{$field->fieldName};
120:                             }
121:                         }
122:                     }
123:                     $model = $oldest;
124:                     $newRecord = $model->isNewRecord;
125:                 }
126:                 if($newRecord){
127:                     $model->createDate = $now;
128:                     $model->assignedTo = $this->controller->getNextAssignee();
129:                 }
130:                 
131:                 $success = $model->save();
132:                 
133:                 
134: 
135:                 //TODO: upload profile picture url from webleadfb
136:                 
137:                 if($success){
138:                     if ($extractedParams['generateLead'])
139:                         self::generateLead ($model, $extractedParams['leadSource']);
140:                     if ($extractedParams['generateAccount'])
141:                         self::generateAccount ($model);
142: 
143:                     self::addTags ($model);
144:                     $tags = ((!isset($_POST['tags']) || empty($_POST['tags'])) ? 
145:                         array() : explode(',',$_POST['tags']));
146:                     if($newRecord) {
147:                         X2Flow::trigger(
148:                             'WebleadTrigger', array('model' => $model, 'tags' => $tags));
149:                     }
150: 
151:                     //use the submitted info to create an action
152:                     Actions::associateAction ($model, array (
153:                         'actionDescription' => 
154:                             Yii::t('contacts', 'Web Lead')
155:                                 ."\n\n".Yii::t('contacts', 'Name').': '.
156:                                 CHtml::decode($model->firstName)." ".
157:                                 CHtml::decode($model->lastName)."\n".Yii::t('contacts', 'Email').
158:                                 ": ".CHtml::decode($model->email)."\n".Yii::t('contacts', 'Phone').
159:                                 ": ".CHtml::decode($model->phone)."\n".
160:                                 Yii::t('contacts', 'Background Info').": ".
161:                                 CHtml::decode($model->backgroundInfo),
162:                         'type' => 'note',
163:                     ));
164: 
165:                     // create a notification if the record is assigned to someone
166:                     $event = new Events;
167:                     $event->associationType = 'Contacts';
168:                     $event->associationId = $model->id;
169:                     $event->user = $model->assignedTo;
170:                     $event->type = 'weblead_create';
171:                     $event->save();
172: 
173:                     
174: 
175:                     if($model->assignedTo != 'Anyone' && $model->assignedTo != '') {
176: 
177:                         $notif = new Notification;
178:                         $notif->user = $model->assignedTo;
179:                         $notif->createdBy = 'API';
180:                         $notif->createDate = time();
181:                         $notif->type = 'weblead';
182:                         $notif->modelType = 'Contacts';
183:                         $notif->modelId = $model->id;
184:                         $notif->save();
185: 
186:                         $profile = Profile::model()->findByAttributes(
187:                             array('username' => $model->assignedTo));
188: 
189:                         /* send user that's assigned to this weblead an email if the user's email
190:                         address is set and this weblead has a user email template */
191:                         if($profile !== null && !empty($profile->emailAddress)){
192: 
193:                             
194:                                 $subject = Yii::t('marketing', 'New Web Lead');
195:                                 $message =
196:                                     Yii::t('marketing',
197:                                         'A new web lead has been assigned to you: ').
198:                                     CHtml::link(
199:                                         $model->firstName.' '.$model->lastName,
200:                                         array('/contacts/contacts/view', 'id' => $model->id)).'.';
201:                                 $address = array('to' => array(array('', $profile->emailAddress)));
202:                                 $emailFrom = Credentials::model()->getDefaultUserAccount(
203:                                     Credentials::$sysUseId['systemNotificationEmail'], 'email');
204:                                 if($emailFrom == Credentials::LEGACY_ID)
205:                                     $emailFrom = array(
206:                                         'name' => $profile->fullName,
207:                                         'address' => $profile->emailAddress
208:                                     );
209: 
210:                                 $status = $this->controller->sendUserEmail(
211:                                     $address, $subject, $message, null, $emailFrom);
212:                             
213:                         }
214: 
215:                     }
216: 
217:                     
218:                 } else {
219:                     $errMsg = 'Error: WebListenerAction.php: model failed to save';
220:                     /**/AuxLib::debugLog ($errMsg);
221:                     Yii::log ($errMsg, '', 'application.debug');
222:                 }
223: 
224:                 $this->controller->renderPartial('application.components.views.webFormSubmit',
225:                     array (
226:                         'type' => 'weblead',
227:                         'redirectUrl' => $extractedParams['redirectUrl']
228:                     )
229:                 );
230: 
231:                 Yii::app()->end(); // success!
232:             }
233:         } 
234: 
235:         $sanitizedGetParams = self::sanitizeGetParams ();
236: 
237:         
238:             $this->controller->renderPartial(
239:                 'application.components.views.webForm', 
240:                 array_merge (array(
241:                     'type' => 'weblead'
242:                 ), $sanitizedGetParams));
243:         
244: 
245:     }
246: 
247: 
248:     private function handleServiceFormSubmission ($model, $extractedParams) {
249:         if(isset($_POST['Services'])){ // web form submitted
250:             if(isset($_POST['Services']['firstName'])){
251:                 $firstName = $_POST['Services']['firstName'];
252:                 $fullName = $firstName;
253:             }
254: 
255:             if(isset($_POST['Services']['lastName'])){
256:                 $lastName = $_POST['Services']['lastName'];
257:                 if(isset($fullName)){
258:                     $fullName .= ' '.$lastName;
259:                 }else{
260:                     $fullName = $lastName;
261:                 }
262:             }
263: 
264:             if(isset($_POST['Services']['email'])){
265:                 $email = $_POST['Services']['email'];
266:             }
267:             if(isset($_POST['Services']['phone'])){
268:                 $phone = $_POST['Services']['phone'];
269:             }
270:             if(isset($_POST['Services']['desription'])){
271:                 $description = $_POST['Services']['description'];
272:             }
273: 
274:             
275: 
276:             // Extra sanitizing
277:             $p = Fields::getPurifier();
278:             foreach($model->attributes as $name=>$value) {
279:                 if($name != $model->primaryKey() && !empty($value)) {
280:                     $model->$name = $p->purify($value);
281:                 }
282:             }
283: 
284:             if(isset($email) && $email) {
285:                 $contact = Contacts::model()->findByAttributes(array('email' => $email));
286:             } else {
287:                 $contact = false;
288:             }
289: 
290:             if($contact){
291:                 $model->contactId = $contact->nameId;
292:             }else{
293:                 $model->contactId = "Unregistered";
294:             }
295: 
296:             if(isset($fullName) || isset($email)){
297:                 $model->subject = Yii::t('services', 'Web Form Case entered by {name}', array(
298:                             '{name}' => isset($fullName) ? $fullName : $email,
299:                 ));
300:             }else{
301:                 $model->subject = Yii::t('services', 'Web Form Case');
302:             }
303: 
304:             $model->origin = 'Web';
305:             if(!isset($model->impact) || $model->impact == '')
306:                 $model->impact = Yii::t('services', '3 - Moderate');
307:             if(!isset($model->status) || $model->status == '')
308:                 $model->status = Yii::t('services', 'New');
309:             if(!isset($model->mainIssue) || $model->mainIssue == '')
310:                 $model->mainIssue = Yii::t('services', 'General Request');
311:             if(!isset($model->subIssue) || $model->subIssue == '')
312:                 $model->subIssue = Yii::t('services', 'Other');
313:             $model->assignedTo = $this->controller->getNextAssignee();
314:             if (isset($email))
315:                 $model->email = CHtml::encode($email);
316:             $now = time();
317:             $model->createDate = $now;
318:             $model->lastUpdated = $now;
319:             $model->updatedBy = 'admin';
320:             if (isset ($description))
321:                 $model->description = CHtml::encode($description);
322: 
323:             
324:             $model->validate (null, false);
325: 
326:             if(!$model->hasErrors()){
327: 
328:                 if($model->save()){
329:                     $model->name = $model->id;
330:                     $model->update(array('name'));
331: 
332:                     self::addTags ($model);
333: 
334:                     //use the submitted info to create an action
335:                     $action = new Actions;
336:                     $action->actionDescription = Yii::t('contacts', 'Web Form')."\n\n".
337:                             (isset($fullName) ? (Yii::t('contacts', 'Name').': '.$fullName."\n") : '').
338:                             (isset($email) ? (Yii::t('contacts', 'Email').": ".$email."\n") : '').
339:                             (isset($phone) ? (Yii::t('contacts', 'Phone').": ".$phone."\n") : '').
340:                             (isset($description) ?
341:                                 (Yii::t('services', 'Description').": ".$description) : '');
342: 
343:                     // create action
344:                     $action->type = 'note';
345:                     $action->assignedTo = $model->assignedTo;
346:                     $action->visibility = '1';
347:                     $action->associationType = 'services';
348:                     $action->associationId = $model->id;
349:                     $action->associationName = $model->name;
350:                     $action->createDate = $now;
351:                     $action->lastUpdated = $now;
352:                     $action->completeDate = $now;
353:                     $action->complete = 'Yes';
354:                     $action->updatedBy = 'admin';
355:                     $action->save();
356: 
357:                     if(isset($email)){
358: 
359:                         //send email
360:                         $emailBody = Yii::t('services', 'Hello').' '.$fullName.",<br><br>";
361:                         $emailBody .= Yii::t('services',
362:                             'Thank you for contacting our Technical Support '.
363:                             'team. This is to verify we have received your request for Case# '.
364:                             '{casenumber}. One of our Technical Analysts will contact you shortly.',
365:                             array('{casenumber}' => $model->id));
366: 
367:                         $emailBody = Yii::app()->settings->serviceCaseEmailMessage;
368:                         if(isset($firstName))
369:                             $emailBody = preg_replace('/{first}/u', $firstName, $emailBody);
370:                         if(isset($lastName))
371:                             $emailBody = preg_replace('/{last}/u', $lastName, $emailBody);
372:                         if(isset($phone))
373:                             $emailBody = preg_replace('/{phone}/u', $phone, $emailBody);
374:                         if(isset($email))
375:                             $emailBody = preg_replace('/{email}/u', $email, $emailBody);
376:                         if(isset($description))
377:                             $emailBody = preg_replace('/{description}/u', $description, $emailBody);
378:                         $emailBody = preg_replace('/{case}/u', $model->id, $emailBody);
379:                         $emailBody = preg_replace('/\n|\r\n/', "<br>", $emailBody);
380: 
381:                         $uniqueId = md5(uniqid(rand(), true));
382:                         $emailBody .= '<img src="'.$this->controller->createAbsoluteUrl(
383:                             '/actions/actions/emailOpened', array('uid' => $uniqueId, 'type' => 'open')).'"/>';
384: 
385:                         $emailSubject = Yii::app()->settings->serviceCaseEmailSubject;
386:                         if(isset($firstName))
387:                             $emailSubject = preg_replace('/{first}/u', $firstName, $emailSubject);
388:                         if(isset($lastName))
389:                             $emailSubject = preg_replace('/{last}/u', $lastName, $emailSubject);
390:                         if(isset($phone))
391:                             $emailSubject = preg_replace('/{phone}/u', $phone, $emailSubject);
392:                         if(isset($email))
393:                             $emailSubject = preg_replace('/{email}/u', $email, $emailSubject);
394:                         if(isset($description))
395:                             $emailSubject = preg_replace('/{description}/u', $description,
396:                                 $emailSubject);
397:                         $emailSubject = preg_replace('/{case}/u', $model->id, $emailSubject);
398:                         if(Yii::app()->settings->serviceCaseEmailAccount != 
399:                            Credentials::LEGACY_ID) {
400:                             $from = (int) Yii::app()->settings->serviceCaseEmailAccount;
401:                         } else {
402:                             $from = array(
403:                                 'name' => Yii::app()->settings->serviceCaseFromEmailName,
404:                                 'address' => Yii::app()->settings->serviceCaseFromEmailAddress
405:                             );
406:                         }
407:                         $useremail = array('to' => array(array(isset($fullName) ?
408:                             $fullName : '', $email)));
409: 
410:                         $status = $this->controller->sendUserEmail(
411:                             $useremail, $emailSubject, $emailBody, null, $from);
412: 
413:                         if($status['code'] == 200){
414:                             if($model->assignedTo != 'Anyone'){
415:                                 $profile = X2Model::model('Profile')->findByAttributes(
416:                                     array('username' => $model->assignedTo));
417:                                 if(isset($profile)){
418:                                     $useremail['to'] = array(
419:                                         array(
420:                                             $profile->fullName,
421:                                             $profile->emailAddress,
422:                                         ),
423:                                     );
424:                                     $emailSubject = 'Service Case Created';
425:                                     $emailBody = "A new service case, #".$model->id.
426:                                         ", has been created in X2Engine. To view the case, click ".
427:                                         "this link: ".$model->getLink();
428:                                     $status = $this->controller->sendUserEmail(
429:                                         $useremail, $emailSubject, $emailBody, null, $from);
430:                                 }
431:                             }
432:                             //email action
433:                             $action = new Actions;
434:                             $action->associationType = 'services';
435:                             $action->associationId = $model->id;
436:                             $action->associationName = $model->name;
437:                             $action->visibility = 1;
438:                             $action->complete = 'Yes';
439:                             $action->type = 'email';
440:                             $action->completedBy = 'admin';
441:                             $action->assignedTo = $model->assignedTo;
442:                             $action->createDate = time();
443:                             $action->dueDate = time();
444:                             $action->completeDate = time();
445:                             $action->actionDescription = '<b>'.$model->subject."</b>\n\n".
446:                                 $emailBody;
447:                             if($action->save()){
448:                                 $track = new TrackEmail;
449:                                 $track->actionId = $action->id;
450:                                 $track->uniqueId = $uniqueId;
451:                                 $track->save();
452:                             }
453:                         } else {
454:                             $errMsg = 'Error: actionWebForm.php: sendUserEmail failed';
455:                             /**/AuxLib::debugLog ($errMsg);
456:                             Yii::log ($errMsg, '', 'application.debug');
457:                         }
458:                     }
459:                     $this->controller->renderPartial('application.components.views.webFormSubmit',
460:                         array('type' => 'service', 'caseNumber' => $model->id));
461: 
462:                     Yii::app()->end(); // success!
463:                 }
464:             }
465:         }
466: 
467:         $sanitizedGetParams = self::sanitizeGetParams ();
468: 
469:         
470:             $this->controller->renderPartial (
471:                 'application.components.views.webForm',
472:                 array_merge (array(
473:                     'model' => $model, 'type' => 'service'
474:                 ), $sanitizedGetParams));
475:         
476:     }
477: 
478: 
479: 
480:     /**
481:      * Create a web lead form with a custom style
482:      *
483:      * There are currently two methods of specifying web form options. 
484:      *  Method 1 (legacy):
485:      *      Web form options are sent in the GET parameters (limited options: css, web form
486:      *      id for retrieving custom header)
487:      *  Method 2 (new):
488:      *      CSS options are passed in the GET parameters and all other options (custom fields, 
489:      *      custom html, and email templates) are stored in the database and accessed via a
490:      *      web form id sent in the GET parameters.
491:      *
492:      * This get request is for weblead/service type only, marketing/weblist/view supplies
493:      * the form that posts for weblist type
494:      *
495:      */
496:     public function run(){
497:         $modelClass = $this->controller->modelClass;
498:         if ($modelClass === 'Campaign') $modelClass = 'Contacts';
499: 
500:         if ($modelClass === 'Contacts')
501:             $model = new Contacts ('webForm');
502:         elseif ($modelClass === 'Services')
503:             $model = new Services ('webForm');
504: 
505:         $extractedParams = array ();
506: 
507:         if (isset ($_GET['webFormId'])) { 
508:             $webForm = WebForm::model()->findByPk($_GET['webFormId']);
509:         } 
510:         $extractedParams['leadSource'] = null;
511:         $extractedParams['generateLead'] = false;
512:         $extractedParams['generateAccount'] = false;
513:         $extractedParams['redirectUrl'] = null;
514:         if (isset ($webForm)) { // new method
515:             if (!empty ($webForm->leadSource)) 
516:                 $extractedParams['leadSource'] = $webForm->leadSource;
517:             if (!empty ($webForm->generateLead)) 
518:                 $extractedParams['generateLead'] = $webForm->generateLead;
519:             if (!empty ($webForm->generateAccount)) 
520:                 $extractedParams['generateAccount'] = $webForm->generateAccount;
521:             if (!empty ($webForm->redirectUrl)) 
522:                 $extractedParams['redirectUrl'] = $webForm->redirectUrl;
523:         }
524: 
525:         
526: 
527:         if ($modelClass === 'Contacts') {
528:             $this->handleWebleadFormSubmission ($model, $extractedParams);
529:         } else if ($modelClass === 'Services') {
530:             $this->handleServiceFormSubmission ($model, $extractedParams);
531:         }
532: 
533:     }
534: 
535:     /**
536:      * Creates a new lead and associates it with the contact
537:      * @param Contacts $contact
538:      * @param null|string $leadSource
539:      */
540:     private static function generateLead (Contacts $contact, $leadSource=null) {
541:         $lead = new X2Leads ('webForm');
542:         $lead->firstName = $contact->firstName;
543:         $lead->lastName = $contact->lastName;
544:         $lead->leadSource = $leadSource;
545:         // disable validation to prevent saving from failing if leadSource isn't set
546:         if ($lead->save (false)) {
547:             $lead->createRelationship($contact);
548:         }
549: 
550:     }
551: 
552:     /**
553:      * Generates an account from the contact's company field, if that field has a value 
554:      */
555:     private static function generateAccount (Contacts $contact) {
556:         if (isset ($contact->company)) {
557:             $account = new Accounts ();
558:             $account->name = $contact->company;
559:             if ($account->save ()) {
560:                 $account->refresh ();
561:                 $contact->company = $account->nameId;
562:                 $contact->update ();
563:             }
564:         }
565:     }
566: 
567: }
568: 
569: ?>
570: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0