public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $this->contact_company = (int) $this->contact_company;
     $this->contact_department = (int) $this->contact_department;
     $this->contact_owner = (int) $this->contact_owner;
     $this->contact_private = (int) $this->contact_private;
     $this->contact_first_name = $this->contact_first_name == null ? '' : $this->contact_first_name;
     $this->contact_last_name = $this->contact_last_name == null ? '' : $this->contact_last_name;
     $this->contact_order_by = $this->contact_order_by == null ? '' : $this->contact_order_by;
     $this->contact_display_name = $this->contact_display_name == null ? '' : $this->contact_display_name;
     $this->contact_birthday = $this->contact_birthday == '' ? null : $this->contact_birthday;
     /*
      *  This  validates that any Contact saved will have a Display Name as
      * required by various dropdowns, etc throughout the system.  This is
      * mostly required when Contacts are generated via programatic methods and
      * not through the add/edit UI.
      */
     if (mb_strlen($this->contact_order_by) <= 1) {
         $this->contact_order_by = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name);
     }
     if (mb_strlen($this->contact_display_name) <= 1) {
         $this->contact_display_name = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name);
     }
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $q = $this->_query;
     $this->contact_lastupdate = $q->dbfnNowWithTZ();
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->contact_id) {
         // && $perms->checkModuleItem('contacts', 'edit', $this->contact_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->contact_id) {
         // && $perms->checkModuleItem('contacts', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if ($stored) {
         $custom_fields = new w2p_Core_CustomFields('contacts', 'addedit', $this->contact_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->contact_id);
         // Store Custom Fields
     }
     if ($stored) {
         $foto = W2P_BASE_DIR . '/fotos/' . $this->contact_id . '.jpg';
         $foto_temp = W2P_BASE_DIR . '/fotos/temp.jpg';
         if (file_exists($foto) && file_exists($foto_temp)) {
             unlink($foto);
         }
         if (file_exists($foto_temp)) {
             rename($foto_temp, $foto);
             if (file_exists($foto_temp)) {
                 unlink($foto_temp);
             }
         }
     }
     /*
      *  TODO: I don't like using the $_POST in here..
      */
     if ($stored) {
         $methods = array();
         if (!empty($_POST['contact_methods'])) {
             foreach ($_POST['contact_methods']['field'] as $key => $field) {
                 $methods[$field] = $_POST['contact_methods']['value'][$key];
             }
         }
         $this->setContactMethods($methods);
     }
     return $stored;
 }
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->w2PTrimAll();
     // ensure changes of state in checkboxes is captured
     $this->project_active = (int) $this->project_active;
     $this->project_private = (int) $this->project_private;
     $this->project_target_budget = filterCurrency($this->project_target_budget);
     $this->project_actual_budget = filterCurrency($this->project_actual_budget);
     // Make sure project_short_name is the right size (issue for languages with encoded characters)
     $this->project_short_name = mb_substr($this->project_short_name, 0, 10);
     if (empty($this->project_end_date)) {
         $this->project_end_date = null;
     }
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $this->project_id = (int) $this->project_id;
     // convert dates to SQL format first
     if ($this->project_start_date) {
         $date = new w2p_Utilities_Date($this->project_start_date);
         $this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_end_date) {
         $date = new w2p_Utilities_Date($this->project_end_date);
         $date->setTime(23, 59, 59);
         $this->project_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_actual_end_date) {
         $date = new w2p_Utilities_Date($this->project_actual_end_date);
         $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     // check project parents and reset them to self if they do not exist
     if (!$this->project_parent) {
         $this->project_parent = $this->project_id;
         $this->project_original_parent = $this->project_id;
     } else {
         $parent_project = new CProject();
         $parent_project->load($this->project_parent);
         $this->project_original_parent = $parent_project->project_original_parent;
     }
     if (!$this->project_original_parent) {
         $this->project_original_parent = $this->project_id;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     $q = $this->_query;
     $this->project_updated = $q->dbfnNowWithTZ();
     if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->project_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) {
         $this->project_created = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             return $msg;
         }
         if (0 == $this->project_parent || 0 == $this->project_original_parent) {
             $this->project_parent = $this->project_id;
             $this->project_original_parent = $this->project_id;
             if ($msg = parent::store()) {
                 return $msg;
             }
         }
         $stored = true;
     }
     //split out related departments and store them seperatly.
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         foreach ($this->project_departments as $department) {
             if ($department) {
                 $q->addTable('project_departments');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('department_id', $department);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         foreach ($this->project_contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     if ($stored) {
         $custom_fields = new w2p_Core_CustomFields('projects', 'addedit', $this->project_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->project_id);
         // Store Custom Fields
         CTask::storeTokenTask($AppUI, $this->project_id);
     }
     return $stored;
 }
Example #3
0
 public function __construct($m, $a, $obj_id = null, $mode = 'edit', $published = 0)
 {
     parent::__construct($m, $a, $obj_id, $mode, $published);
     trigger_error("CustomFields has been deprecated in v2.0 and will be removed by v4.0. Please use w2p_core_CustomFields instead.", E_USER_NOTICE);
 }
Example #4
0
$form->showLabel('Job Title');
?>
                <?php 
$form->showField('contact_job', $object->contact_job, array('maxlength' => 100));
?>
            </p>
            <p>
                <?php 
$form->showLabel('Contact Notes');
?>
                <?php 
$form->showField('contact_notes', $object->contact_notes);
?>
            </p>
            <?php 
$custom_fields = new w2p_Core_CustomFields($m, $a, $object->contact_id, "edit");
echo $custom_fields->getHTML();
$form->showCancelButton();
?>
        </div>
        <div class="column right">
            <p>
                <?php 
$form->showLabel('Address1');
?>
                <?php 
$form->showField('contact_address1', $object->contact_address1, array('maxlength' => 60));
?>
            </p>
            <p>
                <?php 
Example #5
0
		<td width="50%" valign="top">
			<strong><?php 
echo $AppUI->_('Description');
?>
</strong>
			<table cellspacing="0" cellpadding="2" border="0" width="100%">
				<tr>
					<td class="hilite">
            <?php 
echo w2p_textarea($company->company_description);
?>
					</td>
				</tr>		
			</table>
			<?php 
$custom_fields = new w2p_Core_CustomFields($m, $a, $company->company_id, 'view');
$custom_fields->printHTML();
?>
		</td>
	</tr>
</table>

<?php 
// tabbed information boxes
$moddir = W2P_BASE_DIR . '/modules/companies/';
$tabBox = new CTabBox('?m=companies&a=view&company_id=' . $company_id, '', $tab);
$tabBox->add($moddir . 'vw_active', 'Active Projects');
$tabBox->add($moddir . 'vw_archived', 'Archived Projects');
if ($AppUI->isActiveModule('departments') && canView('departments')) {
    $tabBox->add($moddir . 'vw_depts', 'Departments');
}
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     if (!$this->event_recurs) {
         $this->event_times_recuring = 0;
     } else {
         //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date
         //so that the event starts recurring from the start day onwards n times after the start date for the period given
         //Meaning: The event end date day is useless as far as recurring events are concerned.
         $start_date = new w2p_Utilities_Date($this->event_start_date);
         $end_date = new w2p_Utilities_Date($this->event_end_date);
         $hour = $end_date->getHour();
         $minute = $end_date->getMinute();
         $end_date->setDate($start_date->getDate());
         $end_date->setHour($hour);
         $end_date->setMinute($minute);
         $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
     }
     // ensure changes to check boxes and select lists are honoured
     $this->event_private = (int) $this->event_private;
     $this->event_type = (int) $this->event_type;
     $this->event_cwd = (int) $this->event_cwd;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $this->event_start_date = $AppUI->convertToSystemTZ($this->event_start_date);
     $this->event_end_date = $AppUI->convertToSystemTZ($this->event_end_date);
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->event_id && $perms->checkModuleItem('events', 'edit', $this->event_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->event_id && $perms->checkModuleItem('events', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if ($stored) {
         // TODO:  I *really* don't like using the POST inside here..
         $this->updateAssigned(explode(',', $_POST['event_assigned']));
         $custom_fields = new w2p_Core_CustomFields('calendar', 'addedit', $this->event_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->event_id);
         // Store Custom Fields
     }
     return $stored;
 }
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $this->company_id = (int) $this->company_id;
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->company_id && canEdit('companies', $this->company_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->company_id && canAdd('companies')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if ($stored) {
         $custom_fields = new w2p_Core_CustomFields('companies', 'addedit', $this->company_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->company_id);
         // Store Custom Fields
     }
     return $stored;
 }
Example #8
0
?>
:</td>
					<td align="center" nowrap="nowrap">
                        <?php 
echo $contact->contact_lastupdate && !($contact->contact_lastupdate == 0) ? $AppUI->formatTZAwareTime($contact->contact_lastupdate) : '';
?>
                    </td>
				</tr>	
			</table>
		</td>
	</tr>
	<tr>
		<td valign="top" width="50%">
			<table border="0" cellpadding="1" cellspacing="1" class="details" width="100%">
				<?php 
$custom_fields = new w2p_Core_CustomFields($m, $a, $contact->contact_id, 'view');
if ($custom_fields->count()) {
    ?>
							<th colspan="2">
								<strong><?php 
    echo $AppUI->_('Contacts Custom Fields');
    ?>
</strong>
							</th>
							<tr>
								<td colspan="2">
									<?php 
    $custom_fields->printHTML();
    ?>
								</td>
							</tr>
Example #9
0
require_once W2P_BASE_DIR . '/classes/ui.class.php';
$AppUI = new w2p_Core_CAppUI();
$updatekey = w2PgetParam($_POST, 'updatekey', 0);
$contact_id = (int) CContact::getContactByUpdatekey($updatekey);
if (!$contact_id) {
    echo $AppUI->_('You are not authorized to use this page. If you should be authorized please contact the sender to give you another valid link, thank you.');
    exit;
}
$contact = new CContact();
if (!$contact->bind($_POST)) {
    $msg = $AppUI->_('There was an error recording your contact data, please contact the system administrator. Thank you very much.');
} else {
    $result = $contact->store();
    if (is_array($result)) {
        $msg = $AppUI->_('There was an error recording your contact data, please contact the system administrator. Thank you very much.');
    } else {
        $custom_fields = new w2p_Core_CustomFields('contacts', 'addedit', $contact->contact_id, 'edit', 1);
        $custom_fields->bind($_POST);
        $custom_fields->store($contact->contact_id);
        $contact->clearUpdateKey();
        $msg = $AppUI->_('Your contact data has been recorded successfully. Your may now close your browser window.  Thank you very much, ' . $contact->contact_first_name);
    }
}
?>
<html>
	<body>
		<?php 
echo $msg;
?>
	</body>
</html>
Example #10
0
    $text .= sprintf("\"%s\",,,,,,,,\"\",\"0/0/00\",", '' . $contactMethods['phone_mobile']);
    // Fields 51- 60
    if ($contact['contact_type'] != '') {
        $categories = "web2Project; " . $contact['contact_type'];
    } else {
        $categories = "web2Project;";
    }
    $text .= sprintf(",,\"%s\",\"%s\",,,\"%s\",\"%s\",\"%s\",,", $contact['contact_birthday'], $categories, $contact['contact_email'], "SMTP", $contact['contact_first_name'] . " " . $contact['contact_last_name']);
    // Fields 61- 70
    $text .= sprintf(",,,,,\"Unspecified\",,,,,");
    // Fields 71- 80
    $notes = mb_str_replace("\"", "\"\"", $contact['contact_notes']);
    $text .= sprintf("\"\",\"\",\"\",,,\"%s\",,,,\"Normal\",", $notes);
    // Fields 81- 90
    $text .= sprintf("\"False\",,,\"Normal\",,,,,,,");
    $custom_fields = w2p_Core_CustomFields::getCustomFieldByModule($AppUI, 'contacts', $contact['contact_id']);
    if (count($custom_fields) > 0) {
        foreach ($custom_fields as $f) {
            if ($f['value_intvalue']) {
                $text .= sprintf("%s", $f['list_value'] . ",");
            } else {
                $text .= sprintf("%s", "\"" . mb_str_replace("\r\n", " ", $f['value_charvalue']) . "\",");
            }
        }
    }
    $text .= sprintf("%s\r\n", '');
}
//send http-output in csv format
// BEGIN extra headers to resolve IE caching bug (JRP 9 Feb 2003)
// [http://bugs.php.net/bug.php?id=16173]
header('Pragma: ');
Example #11
0
if ($obj) {
    $field = $obj;
    $field_id = $field->field_id;
} else {
    $field->load($field_id);
}
$module = new w2p_System_Module();
$module->load($module_id);
$ttl = $field_id ? 'Edit Custom Fields' : 'Add Custom Fields';
$ttl = $AppUI->_($ttl) . ' - ' . $AppUI->_($module->mod_name) . ' ' . $AppUI->_('Module');
$titleBlock = new w2p_Theme_TitleBlock($ttl, 'customfields.png', $m);
$titleBlock->addCrumb('?m=system', 'system admin');
$titleBlock->addCrumb('?m=system&u=customfields', 'custom fields');
$titleBlock->show();
$html_types = $field->getTypes();
$custom_fields = new w2p_Core_CustomFields($module->mod_name, 'addedit', null, 'edit');
if ($field_id) {
    $cf = $custom_fields->fieldWithId($field_id);
    if (is_object($cf)) {
        $field_name = $cf->fieldName();
        $field_description = $cf->fieldDescription();
        $field_htmltype = $cf->fieldHtmlType();
        $field_extratags = $cf->fieldExtraTags();
        $field_order = $cf->fieldOrder();
        $field_published = $cf->fieldPublished();
        if ($field_htmltype == 'select') {
            $select_options = new w2p_Core_CustomOptionList($field_id);
            $select_options->load();
            $select_items = $select_options->getOptions();
        }
    } else {
 protected function hook_postStore()
 {
     // TODO:  I *really* don't like using the POST inside here..
     $this->updateAssigned(explode(',', $_POST['event_assigned']));
     $custom_fields = new w2p_Core_CustomFields('calendar', 'addedit', $this->event_id, 'edit');
     $custom_fields->bind($_POST);
     $custom_fields->store($this->event_id);
     // Store Custom Fields
     parent::hook_postStore();
 }
Example #13
0
}
$result = $obj->store($AppUI);
if (is_array($result)) {
    $AppUI->setMsg($result, UI_MSG_ERROR, true);
    $AppUI->holdObject($obj);
    $AppUI->redirect('m=tasks&a=addedit');
}
if ($result) {
    $task_parent = (int) w2PgetParam($_POST, 'task_parent', 0);
    $old_task_parent = (int) w2PgetParam($_POST, 'old_task_parent', 0);
    if ($task_parent != $old_task_parent) {
        $oldTask = new CTask();
        $oldTask->load($old_task_parent);
        $oldTask->updateDynamics(false);
    }
    $custom_fields = new w2p_Core_CustomFields($m, 'addedit', $obj->task_id, 'edit');
    $custom_fields->bind($_POST);
    $sql = $custom_fields->store($obj->task_id);
    // Store Custom Fields
    // Now add any task reminders
    // If there wasn't a task, but there is one now, and
    // that task date is set, we need to set a reminder.
    if (empty($task_end_date) || !empty($end_date) && $task_end_date->dateDiff($end_date)) {
        $obj->addReminder();
    }
    $AppUI->setMsg($task_id ? 'Task updated' : 'Task added', UI_MSG_OK);
    if (isset($hassign)) {
        $obj->updateAssigned($hassign, $hperc_assign_ar);
    }
    if (isset($hdependencies)) {
        // there are dependencies set!
 /**
  * This method is called within $this->store() but only after the object
  *   was stored properly. You might use this to send notifications or
  *   update other objects.
  * @todo TODO: I REALLY hate this $_POST here.. it's just asking for trouble.
  *
  * @return \w2p_Core_BaseObject
  */
 protected function hook_postStore()
 {
     $custom_fields = new w2p_Core_CustomFields($this->_tbl_module, 'addedit', $this->{$this->_tbl_key}, 'edit');
     $custom_fields->bind($_POST);
     $custom_fields->store($this->{$this->_tbl_key});
     $prefix = $this->_getColumnPrefixFromTableName($this->_tbl);
     $name = '' != $this->{$prefix . '_name'} ? $this->{$prefix . '_name'} : '';
     addHistory($this->_tbl, $this->{$this->_tbl_key}, $this->_event, $name . ' - ' . $this->_AppUI->_('ACTION') . ': ' . $this->_event . ' ' . $this->_AppUI->_('TABLE') . ': ' . $this->_tbl . ' ' . $this->_AppUI->_('ID') . ': ' . $this->{$this->_tbl_key});
     return $this;
 }