Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translations for custom views and make working custom part #151

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions language/en-GB/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ COBALT_COMPANY_DEAL_PERSON = "Company, Deal, Person"
COBALT_ASSOCIATE = "Associate to"
COBALT_ASSOCIATED_DEALS = "Associated Deals"
COBALT_HELLO = "Hello"
COBALT_COMPANY_WEBSITE="Website"

COBALT_DEAL_HEADER="Add Deal"
COBALT_DEAL_NAME="Name"
Expand Down Expand Up @@ -1719,3 +1720,18 @@ POSTGRESQL="PostgreSQL"
SQLAZURE="Microsoft SQL Azure"
SQLITE="SQLite"
SQLSRV="Microsoft SQL Server"

; Edit page for custom fields
COBALT_EDITING_CUSTOM_FIELD_SELECT_TYPE="Select Custom Field Type"
COBALT_EDITING_CUSTOM_FIELD_INFORMATION="Field Information"
COBALT_EDITING_CUSTOM_FIELD_NUMERIC_FIELD_DESC="Numeric Fields can be used to capture items such as product units or other numeric values related to your companies."
COBALT_EDITING_CUSTOM_FIELD_REQUIRED="Make this field a required entry."
COBALT_EDITING_CUSTOM_FIELD_TEXT_FIELD_DESC="Text Fields are used to capture free form text. Examples: Billing Street Address, Email Address."
COBALT_EDITING_CUSTOM_FIELD_CURRENCY_FIELD="Currency Fields are used to capture items that have a $ monetary value. Examples: Service Revenue $, Product Sales $"
COBALT_EDITING_CUSTOM_FIELD_PICKLIST_FIELD_DESC="Picklist fields allow you to specify a list of pre-defined values for a user to pick from. Examples: Industry, Competitor, Regions, Product or Service Interest."
COBALT_EDITING_CUSTOM_FIELD_ENTER_CHOICE="Enter Choice"
COBALT_EDITING_CUSTOM_FIELD_REMOVE="Remove"
COBALT_EDITING_CUSTOM_FIELD_ADD_MORE_CHOICES="Add More Choices"
COBALT_EDITING_CUSTOM_FIELD_SELECT_MORE_THAN_ONE="Users can select more than one value"
COBALT_EDITING_CUSTOM_FIELD_DATE_FIELD_DESC="Date fields allow you to capture important dates related to your companies."
COBALT_PERSON_CUSTOM_FIELDS_DISPLAY="Custom fields"
4 changes: 3 additions & 1 deletion src/Cobalt/Helper/CobaltHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public static function storeCustomCf($id,$cf_data,$type)
$date = DateHelper::formatDBDate(date('Y-m-d H:i:s'));

//Loop through $cf_data array to update/insert
for ( $i=0; $i<count($cf_data); $i++ ) {
$total = count($cf_data);;

for ( $i=0; $i<$total; $i++ ) {
//assign the data
$row = $cf_data[$i];

Expand Down
5 changes: 5 additions & 0 deletions src/Cobalt/Model/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public function store()

$data['modified'] = $date;

if ( empty($data['id']) )
{
unset($data['id']);
}

// Bind the form fields to the table
try
{
Expand Down
27 changes: 12 additions & 15 deletions src/Cobalt/Model/People.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function store($data = null)

//generate custom field string
$customArray = array();

foreach ($data as $name => $value)
{
if (strstr($name, 'custom_') && !strstr($name, '_input') && !strstr($name, "_hidden"))
Expand Down Expand Up @@ -182,14 +182,11 @@ public function store($data = null)
//bind to cf tables for deal & person association
if (isset($data['deal_id']) && $data['deal_id'])
{
$deal = array(
'association_id = ' . $data['deal_id'],
'association_type="deal"',
'person_id = ' . $row->id,
"created = '$date'"
);
$columns = array('association_id', 'association_type', 'person_id', 'created');

$values = array($data['deal_id'], $this->getDb()->quote('deal'), $row->id, $this->getDb()->quote($date));

if (!$this->dealsPeople($deal))
if (!$this->dealsPeople($columns, $values))
{
return false;
}
Expand Down Expand Up @@ -239,16 +236,16 @@ public function associateJoomlaUser($email)
/*
* Method to link deals and people in cf tables
*/
public function dealsPeople($cfdata)
public function dealsPeople($columns, $values)
{
$db = $this->getDb();

// TODO - Refactor to use insert/columns/values methods instead
return $db->setQuery(
$db->getQuery(true)
->insert('#__people_cf')
->set($cfdata)
)->execute();
$query
->insert($db->quoteName('#__people_cf'))
->columns($db->quoteName($columns))
->values(implode(',', $values));

return $db->setQuery($query)->execute();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Cobalt/View/Companies/tmpl/company.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@
<?php if ($company->twitter_user) { ?>
<div class="widget">
<h2><?php echo TextHelper::_('COBALT_LATEST_TWEETS'); ?></h2>
<?php if ( isset($company->tweets) ){ for ($i = 0; $i < count($company->tweets); $i++) {
<?php $total = count($company->tweets);
if ( isset($company->tweets) ){ for ($i = 0; $i < $total; $i++) {
$tweet = $company->tweets[$i];
?>
<div class="tweet">
Expand Down
6 changes: 1 addition & 5 deletions src/Cobalt/View/Companies/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,7 @@ class="form-control"
</div>
</div>
<div class="tab-pane fade in" id="Custom">
<?php if ($format != "raw")
{ ?>
<?php echo $this->edit_custom_fields_view->display(); ?>
<?php
} ?>
<?php echo $this->edit_custom_fields_view->render(); ?>
</div>

<?php if (isset($this->company->id) && $this->company->id) { ?>
Expand Down
38 changes: 19 additions & 19 deletions src/Cobalt/View/Companycustom/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
</label>
<div class="col-sm-10">
<select class="form-control required" id="select-custom-type" name="type">
<option value="">- Select Custom Field Type -</option>
<option value="">- <?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_SELECT_TYPE"); ?> -</option>
<?php echo JHtml::_('select.options', $this->custom_types, 'value', 'text', $this->custom->type, true);?>
</select>
</div>
</div>

<legend>Field Information</legend>
<legend><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_INFORMATION"); ?></legend>

<div id="custom_field_data"></div>
<div>
Expand All @@ -68,40 +68,40 @@
<div class="hide" id="custom_field_templates">
<div id="custom_field_number">
<ul>
<li>Numeric Fields can be used to capture items such as product units or other numeric values related to your companies.</li>
<li><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_NUMERIC_FIELD_DESC"); ?></li>
</ul>
<table>
<tr>
<td><input type="checkbox" name="required" <?php if ( $this->custom->required) echo 'checked'; ?> /></td>
<td>Make this field a required entry.</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_REQUIRED"); ?></td>
</tr>
</table>
</div>
<div id="custom_field_text">
<ul>
<li>Text Fields are used to capture free form text. Examples: Billing Street Address, Email Address.</li>
<li><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_TEXT_FIELD_DESC"); ?></li>
</ul>
<table>
<tr>
<td><input type="checkbox" name="required" <?php if ( $this->custom->required) echo 'checked'; ?> /></td>
<td>Make this field a required entry.</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_REQUIRED"); ?></td>
</tr>
</table>
</div>
<div id="custom_field_currency">
<ul>
<li>Currency Fields are used to capture items that have a $ monetary value. Examples: Service Revenue $, Product Sales $</li>
<li><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_CURRENCY_FIELD"); ?></li>
</ul>
<table>
<tr>
<td><input type="checkbox" name="required" <?php if ( $this->custom->required) echo 'checked'; ?> /></td>
<td>Make this field a required entry.</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_REQUIRED"); ?></td>
</tr>
</table>
</div>
<div id="custom_field_picklist">
<ul>
<li>Picklist fields allow you to specify a list of pre-defined values for a user to pick from. Examples: Industry, Competitor, Regions, Product or Service Interest.</li>
<li><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_PICKLIST_FIELD_DESC"); ?></li>
</ul>
<div id="choices">
<?php if (isset($this->custom->values) && $this->custom->values != null) {
Expand All @@ -111,7 +111,7 @@
<div class="choices">
<table>
<tr>
<td>Enter Choice</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_ENTER_CHOICE"); ?></td>
<td><input class="form-control required" type="text" name="values[]" value="<?php echo $value; ?>" /></td>
<td><a class="btn btn-danger remove_values">Remove</a></td>
</tr>
Expand All @@ -122,49 +122,49 @@
<div class="choices">
<table>
<tr>
<td>Enter Choice</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_ENTER_CHOICE"); ?></td>
<td><input class="form-control required" type="text" name="values[]" value="" /></td>
<td><a class="btn btn-danger remove_values">Remove</a></td>
<td><a class="btn btn-danger remove_values"><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_REMOVE"); ?></a></td>
</tr>
</table>
</div>
<?php } ?>
</div>
<table>
<tr>
<td><a class="btn btn-primary" id="add_values">Add More Choices</a></td>
<td><a class="btn btn-primary" id="add_values"><?php echo TextHelper::_("BALT_EDITING_CUSTOM_FIELD_ADD_MORE_CHOICES"); ?></a></td>
</tr>
</table>
<table>
<tr>
<td><input type="checkbox" name="multiple_selections" <?php if ( $this->custom->multiple_selections) echo 'checked'; ?> /></td>
<td>Users can select more than one value</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_SELECT_MORE_THAN_ONE"); ?></td>
</tr>
<tr>
<td><input type="checkbox" name="required" <?php if ( $this->custom->required) echo 'checked'; ?> /></td>
<td>Make this field a required entry.</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_REQUIRED"); ?></td>
</tr>
</table>
</div>
<div id="choice_template">
<div class="choices">
<table>
<tr>
<td>Enter Choice</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_ENTER_CHOICE"); ?></td>
<td><input class="form-control required" type="text" name="values[]" value="" /></td>
<td><a class="btn btn-danger remove_values">Remove</a></td>
<td><a class="btn btn-danger remove_values"><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_REMOVE"); ?></a></td>
</tr>
</table>
</div>
</div>
<div id="custom_field_date">
<ul>
<li>Date fields allow you to capture important dates related to your companies.</li>
<li><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_DATE_FIELD_DESC"); ?></li>
</ul>
<table>
<tr>
<td><input type="checkbox" name="required" <?php if ( $this->custom->required) echo 'checked'; ?> /></td>
<td>Make this field a required entry.</td>
<td><?php echo TextHelper::_("COBALT_EDITING_CUSTOM_FIELD_REQUIRED"); ?></td>
</tr>
</table>
</div>
Expand Down
19 changes: 12 additions & 7 deletions src/Cobalt/View/Custom/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
// no direct access
defined( '_CEXEC' ) or die( 'Restricted access' );

echo '<div class="clearfix padding">';
echo '</div>';

$custom = DropdownHelper::generateCustom($this->type, is_array($this->item) ? $this->item['id'] : $this->item->id );
$count = 0;
echo '<div class="custom-fields">';
echo '<table class="table table-striped table-hover table-bordered">';

$item_id = is_array($this->item) ? $this->item['id'] : $this->item->id;

if (count($custom) > 0)
{
foreach ($custom as $field => $value)
Expand Down Expand Up @@ -57,18 +62,18 @@
<span class="editable parent" id="editable_custom_<?php echo $value['id']; ?>_container">
<div class="list-inline" id="editable_custom_<?php echo $value['id']; ?>">
<a href="#" data-toggle="popover" data-title="<?php echo TextHelper::_('COBALT_UPDATE_FIELD').' '.$value['name']; ?>" data-html='true' data-content-class="currency-form_<?php echo $value['id']; ?>">
<span id="custom_<?php echo $value['id']; ?>_<?php echo $this->item->id; ?>"><?php echo $custom_field_filter; ?></span>
<span id="custom_<?php echo $value['id']; ?>_<?php echo $item_id; ?>"><?php echo $custom_field_filter; ?></span>
</a>
</div>
</span>
<div class="clearfix currency-form_<?php echo $value['id']; ?> hidden input-append">
<form action="<?php echo RouteHelper::_('index.php'); ?>" method="post" id="amount_form_<?php echo $value['id']; ?>" onsubmit="return Cobalt.sumbitForm(this)" role="form">
<div class="input-group">
<input
placeholder="<?php echo TextHelper::_('COBALT_CLICK_TO_EDIT'); ?>"
type="text"
class="form-control input-small"
name="custom_<?php echo $value['id']; ?>"
<input
placeholder="<?php echo TextHelper::_('COBALT_CLICK_TO_EDIT'); ?>"
type="text"
class="form-control input-small"
name="custom_<?php echo $value['id']; ?>"
value="<?php echo $value['selected']; ?>" />
<span class="input-group-btn">
<button type="submit" class="btn btn-default">
Expand All @@ -78,7 +83,7 @@ class="form-control input-small"
</div>
<input type="hidden" name="task" value="save" />
<input type="hidden" name="model" value="<?php echo $this->type; ?>" />
<input type="hidden" name="id" value="<?php echo $this->item->id; ?>" />
<input type="hidden" name="id" value="<?php echo $item_id; ?>" />
</form>
</div>
<?php break;
Expand Down
Loading