Пример #1
0
<?php

set_page_title(lang('billing categories'));
$isBillingEnabled = can_manage_billing(logged_user()) && isset($billing_categories) && is_array($billing_categories) && count($billing_categories);
?>
<div class="adminBilling" style="height:100%;background-color:white">
  <div class="coInputHeader">

	  <div class="coInputHeaderUpperRow">
		<div class="coInputTitle">
			<?php 
echo lang('billing categories');
?>
		</div>
	  </div>
	
	</div>
	
	<div class="coInputMainBlock adminMainBlock">

<?php 
if ($isBillingEnabled) {
    echo lang('billing support is enabled');
    ?>
<br/>
<table style="min-width:400px;margin-top:10px;border:1px solid #DDD">
  <tr>
    <th><?php 
    echo lang('name');
    ?>
</th>
Пример #2
0
 function add_timeslot()
 {
     if (!can_add(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $timeslot_data = array_var($_POST, 'timeslot');
     try {
         $hoursToAdd = array_var($timeslot_data, 'hours', 0);
         $minutes = array_var($timeslot_data, 'minutes', 0);
         if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
             $hoursToAdd = str_replace(',', '.', $hoursToAdd);
         }
         if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
             $pos = strpos($hoursToAdd, ':') + 1;
             $len = strlen($hoursToAdd) - $pos;
             $minutesToAdd = substr($hoursToAdd, $pos, $len);
             if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
                 $minutesToAdd = substr($minutesToAdd, 0, 2);
             }
             $mins = $minutesToAdd / 60;
             $hours = substr($hoursToAdd, 0, $pos - 1);
             $hoursToAdd = $hours + $mins;
         }
         if ($minutes) {
             $min = str_replace('.', '', $minutes / 6);
             $hoursToAdd = $hoursToAdd + ("0." . $min);
         }
         if ($hoursToAdd <= 0) {
             flash_error(lang('time has to be greater than 0'));
             return;
         }
         $startTime = getDateValue(array_var($timeslot_data, 'date'));
         $startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
         $endTime = getDateValue(array_var($timeslot_data, 'date'));
         $endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
         $timeslot_data['start_time'] = $startTime;
         $timeslot_data['end_time'] = $endTime;
         $timeslot_data['name'] = $timeslot_data['description'];
         $timeslot_data['object_id'] = 0;
         //array_var($timeslot_data,'project_id');
         $timeslot = new Timeslot();
         //Only admins can change timeslot user
         if (!array_var($timeslot_data, 'contact_id', false) || !logged_user()->isAdministrator()) {
             $timeslot_data['contact_id'] = logged_user()->getId();
         }
         $timeslot->setFromAttributes($timeslot_data);
         $user = Contacts::findById($timeslot_data['contact_id']);
         $billing_category_id = $user->getDefaultBillingId();
         $bc = BillingCategories::findById($billing_category_id);
         if ($bc instanceof BillingCategory) {
             $timeslot->setBillingId($billing_category_id);
             $hourly_billing = $bc->getDefaultValue();
             $timeslot->setHourlyBilling($hourly_billing);
             $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
             $timeslot->setIsFixedBilling(false);
         }
         DB::beginWork();
         $timeslot->save();
         $member_ids = array();
         $context = active_context();
         foreach ($context as $selection) {
             if ($selection instanceof Member) {
                 $member_ids[] = $selection->getId();
             }
         }
         $object_controller = new ObjectController();
         $object_controller->add_to_members($timeslot, $member_ids);
         DB::commit();
         $show_billing = can_manage_billing(logged_user());
         ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo($show_billing)));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
Пример #3
0
		'extra' => '<a class="internalLink coViewAction ico-add" href="' . get_url('contact', 'add_company') . '">' . lang('add company') . '</a>'
	);
}*/
if (can_manage_security(logged_user())) {
    $icons[] = array('ico' => 'ico-large-user', 'url' => get_url('administration', 'members'), 'name' => lang('users'), 'extra' => '<a class="internalLink coViewAction ico-add" href="' . owner_company()->getAddUserUrl() . '">' . lang('add user') . '</a>');
}
if (can_manage_security(logged_user())) {
    $icons[] = array('ico' => 'ico-large-group', 'url' => get_url('administration', 'groups'), 'name' => lang('groups'), 'extra' => '<a class="internalLink coViewAction ico-add" href="' . owner_company()->getAddGroupUrl() . '">' . lang('add group') . '</a>');
}
if (can_manage_security(logged_user()) && Plugins::instance()->isActivePlugin('mail')) {
    $icons[] = array('ico' => 'ico-large-email', 'url' => get_url('administration', 'mail_accounts'), 'name' => lang('mail accounts'), 'extra' => '<a class="internalLink coViewAction ico-add" href="' . get_url('mail', 'add_account') . '">' . lang('add mail account') . '</a>');
}
if (can_manage_templates(logged_user())) {
    $icons[] = array('ico' => 'ico-large-template', 'url' => get_url('template', 'index'), 'name' => lang('templates'), 'extra' => '<a class="internalLink coViewAction ico-add" href="' . get_url('template', 'add') . '">' . lang('add template') . '</a>');
}
if (can_manage_billing(logged_user())) {
    $icons[] = array('ico' => 'ico-large-billing', 'url' => get_url('billing', 'index'), 'name' => lang('billing'), 'extra' => '<a class="internalLink coViewAction ico-add" href="' . get_url('billing', 'add') . '">' . lang('add billing category') . '</a>');
}
if (can_manage_configuration(logged_user())) {
    $icons[] = array('ico' => 'ico-large-company', 'url' => get_url('administration', 'company'), 'name' => lang('organization data'), 'extra' => '');
    $icons[] = array('ico' => 'ico-large-custom-properties', 'url' => get_url('administration', 'custom_properties'), 'name' => lang('custom properties'), 'extra' => '');
    /*
    	$icons[] = array(
    		'ico' => 'ico-large-object-subtypes',
    		'url' => get_url('administration', 'object_subtypes'),
    		'name' => lang('object subtypes'),
    		'extra' => '',
    	);*/
    $icons[] = array('ico' => 'ico-large-configuration', 'url' => get_url('administration', 'configuration'), 'name' => lang('configuration'), 'extra' => '');
    $icons[] = array('ico' => 'ico-large-tools', 'url' => get_url('administration', 'tools'), 'name' => lang('administration tools'), 'extra' => '');
    /*FIXME if (!defined('ALLOW_UPGRADING') || ALLOW_UPGRADING) {
Пример #4
0
	<?php if(logged_user()->isAdministrator()) : ?>
	    <div class="formBlock">
	      <?php echo label_tag(lang('username'), $genid . 'profileFormUsername', true) ?>
	      <?php echo text_field('user[username]', array_var($user_data, 'username'), array('id' => $genid . 'profileFormUsername', 'tabindex' => '2000')) ?>
	    </div>
		
	<?php else: ?>
		<div>
		  <?php echo label_tag(lang('username')) ?>
		  <?php echo clean(array_var($user_data, 'username')) ?>
		  <input type="hidden" name="user[username]" value="<?php echo clean(array_var($user_data, 'username')) ?>" />
		</div>
	<?php endif; ?>
    <input type="hidden" name="user[company_id]" value="<?php echo array_var($user_data, 'company_id')?>" /> 
	
<?php if (can_manage_billing(logged_user()) && isset($billing_categories) && count($billing_categories) > 0) {?>
	<div id="<?php echo $genid ?>update_profile_billing" style="display:none">
		
		<fieldset>
			<legend><?php echo lang('billing') ?></legend>
			<?php 
				$options = array(option_tag(lang('select billing category'),0,($user->getDefaultBillingId() == 0?array('selected' => 'selected'):null)));
				foreach ($billing_categories as $category){
					$options[] = option_tag($category->getName(), $category->getId(), ($category->getId()==$user->getDefaultBillingId())?array('selected' => 'selected'):null);	
				}
				echo label_tag(lang('billing category'), null, false);
				echo select_box('user[default_billing_id]', $options, array('id' => 'userDefaultBilling'));
			?>
		</fieldset>
		
	</div>
 function update_unset_billing_values()
 {
     ajx_current("empty");
     if (!can_manage_billing(logged_user())) {
         flash_error(lang("no access permissions"));
         return;
     }
     try {
         DB::beginWork();
         $count = Timeslots::updateBillingValues();
         DB::commit();
         flash_success(lang("success update billing values", $count));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
 }
Пример #6
0
 function add_timeslot()
 {
     $object_id = array_var($_REQUEST, "object_id", false);
     ajx_current("empty");
     $timeslot_data = array_var($_POST, 'timeslot');
     if ($object_id) {
         $object = Objects::findObject($object_id);
         if (!$object instanceof ContentDataObject || !$object->canAddTimeslot(logged_user())) {
             flash_error(lang('no access permissions'));
             ajx_current("empty");
             return;
         }
         $member_ids = $object->getMemberIds();
     } else {
         $member_ids = json_decode(array_var($_POST, 'members', array()));
         // clean member_ids
         $tmp_mids = array();
         foreach ($member_ids as $mid) {
             if (!is_null($mid) && trim($mid) != "") {
                 $tmp_mids[] = $mid;
             }
         }
         $member_ids = $tmp_mids;
         if (empty($member_ids)) {
             if (!can_add(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
                 flash_error(lang('no access permissions'));
                 ajx_current("empty");
                 return;
             }
         } else {
             if (count($member_ids) > 0) {
                 $enteredMembers = Members::findAll(array('conditions' => 'id IN (' . implode(",", $member_ids) . ')'));
             } else {
                 $enteredMembers = array();
             }
             if (!can_add(logged_user(), $enteredMembers, Timeslots::instance()->getObjectTypeId())) {
                 flash_error(lang('no access permissions'));
                 ajx_current("empty");
                 return;
             }
         }
         $object_id = 0;
     }
     try {
         $hoursToAdd = array_var($timeslot_data, 'hours', 0);
         $minutes = array_var($timeslot_data, 'minutes', 0);
         if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
             $hoursToAdd = str_replace(',', '.', $hoursToAdd);
         }
         if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
             $pos = strpos($hoursToAdd, ':') + 1;
             $len = strlen($hoursToAdd) - $pos;
             $minutesToAdd = substr($hoursToAdd, $pos, $len);
             if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
                 $minutesToAdd = substr($minutesToAdd, 0, 2);
             }
             $mins = $minutesToAdd / 60;
             $hours = substr($hoursToAdd, 0, $pos - 1);
             $hoursToAdd = $hours + $mins;
         }
         if ($minutes) {
             $min = str_replace('.', '', $minutes / 6);
             $hoursToAdd = $hoursToAdd + ("0." . $min);
         }
         if ($hoursToAdd <= 0) {
             flash_error(lang('time has to be greater than 0'));
             return;
         }
         $startTime = getDateValue(array_var($timeslot_data, 'date'));
         $startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
         $endTime = getDateValue(array_var($timeslot_data, 'date'));
         $endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
         //use current time
         if (array_var($_REQUEST, "use_current_time", false)) {
             $currentStartTime = DateTimeValueLib::now();
             $currentEndTime = DateTimeValueLib::now();
             $currentStartTime = $currentStartTime->add('h', -$hoursToAdd);
             $startTime->setHour($currentStartTime->getHour());
             $startTime->setMinute($currentStartTime->getMinute());
             $endTime->setHour($currentEndTime->getHour());
             $endTime->setMinute($currentEndTime->getMinute());
         }
         $timeslot_data['start_time'] = $startTime;
         $timeslot_data['end_time'] = $endTime;
         $timeslot_data['description'] = html_to_text($timeslot_data['description']);
         $timeslot_data['name'] = $timeslot_data['description'];
         $timeslot_data['rel_object_id'] = $object_id;
         //array_var($timeslot_data,'project_id');
         $timeslot = new Timeslot();
         //Only admins can change timeslot user
         if (!array_var($timeslot_data, 'contact_id', false) || !SystemPermissions::userHasSystemPermission(logged_user(), 'can_manage_time')) {
             $timeslot_data['contact_id'] = logged_user()->getId();
         }
         $timeslot->setFromAttributes($timeslot_data);
         $user = Contacts::findById($timeslot_data['contact_id']);
         $billing_category_id = $user->getDefaultBillingId();
         $bc = BillingCategories::findById($billing_category_id);
         if ($bc instanceof BillingCategory) {
             $timeslot->setBillingId($billing_category_id);
             $hourly_billing = $bc->getDefaultValue();
             $timeslot->setHourlyBilling($hourly_billing);
             $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
             $timeslot->setIsFixedBilling(false);
         }
         DB::beginWork();
         $timeslot->save();
         $task = ProjectTasks::findById($object_id);
         if ($task instanceof ProjectTask) {
             $task->calculatePercentComplete();
         }
         if (!isset($member_ids) || !is_array($member_ids) || count($member_ids) == 0) {
             $member_ids = json_decode(array_var($_POST, 'members'));
         }
         $object_controller = new ObjectController();
         $object_controller->add_to_members($timeslot, $member_ids);
         DB::commit();
         ApplicationLogs::createLog($timeslot, ApplicationLogs::ACTION_ADD);
         $show_billing = can_manage_billing(logged_user());
         ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo($show_billing), "real_obj_id" => $timeslot->getRelObjectId()));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
Пример #7
0
 
	      		<label for="<?php 
    echo 'report[include_unworked]';
    ?>
" class="checkbox"><?php 
    echo lang('include unworked pending tasks');
    ?>
</label>
			</td>
		</tr>
		<?php 
}
?>
		
		<?php 
if ($has_billing && can_manage_billing(logged_user())) {
    ?>
		<tr style='height:30px;'>
			<td><span class="bold"><?php 
    echo lang('show billing information');
    ?>
</span></td>
			<td align='left' style="padding-left:10px;">
				<?php 
    echo checkbox_field('report[show_billing]', array_var($report_data, 'show_billing', false), array("id" => "report[show_billing]"));
    ?>
			</td>
		</tr>
		<?php 
}
?>
Пример #8
0
<?php

$genid = gen_id();
$gs_step = config_option('getting_started_step');
$all_set = array_var($_REQUEST, 'more_settings_expanded');
?>

<div class="more-panel-container">
	<div class="title"><?php 
echo lang('learn about and manage your Feng Office');
?>
</div>

<?php 
if (can_manage_configuration(logged_user()) || can_manage_security(logged_user()) || can_manage_templates(logged_user()) || can_manage_billing(logged_user())) {
    ?>
	<div class="more-panel-section">
		<h1><?php 
    echo lang('quick system configuration and settings');
    ?>
</h1>
		<div class="section-content section1" style="<?php 
    echo $gs_step < 99 && !$all_set ? "max-width:100%;" : "";
    ?>
">
		<?php 
    tpl_assign('genid', $genid);
    $this->includeTemplate(get_template_path('section1', 'more'));
    ?>
		</div>
	</div>