function removeTel(id)
{
- $('#' + id).remove();
+ var total = 0;
+ while ($('#tels_' + total).length != 0) {
+ ++total;
+ }
+ $('#tels_' + id).remove();
+ for (var i = parseInt(id) + 1; i < total; ++i) {
+ renumberPhone(i);
+ }
}
function addPhoneComment(id)
$('#' + id + '_addComment').show();
}
+function renumberPhone(i)
+{
+ var telid = i - 1;
+ var telprefOld = 'tels[' + i + ']';
+ var telpref = 'tels[' + telid + ']';
+ var idOld = 'tels_' + i;
+ var id = 'tels_' + telid;
+
+ $('#tels_' + i).attr('id', 'tels_' + telid);
+ $('#tels_' + telid).find('div.titre').html('N°' + i);
+ $('#tels_' + telid).find('a.removeTel').attr('href', 'javascript:removeTel(' + telid + ')');
+ $('#tels_' + telid).find('select').attr('name', telpref + '[type]');
+ $('#tels_' + telid).find("[name='" + telprefOld + "[tel]']").attr('name', telpref + '[tel]');
+ $('#tels_' + telid).find("[name='" + telprefOld + "[comment]']").attr('name', telpref + '[comment]');
+ $('#tels_' + telid).find('a.removePhoneComment').attr('href', 'javascript:removePhoneComment(' + id + ',' + telpref + ')');
+ $('#tels_' + telid).find('#' + idOld + '_addComment').attr('id', id + '_addComment');
+ $('#tels_' + telid).find('#' + id + '_addComment').attr('href', 'javascript:addPhoneComment(' + id + ')');
+ $('#tels_' + telid).find('#' + idOld + '_comment').attr('id', id + '_comment');
+ $('#tels_' + telid).find("[name='" + telprefOld + "[pub]']").attr('name', telpref + '[pub]');
+}
+
// {{{1 Groups
function addBinet()
}
foreach ($value as $key => &$address) {
if (isset($address['removed']) && $address['removed']) {
- unset($value[$key]);
+ array_splice($value, $key, 1);
}
}
$current = 0;
$success = false;
}
if (isset($job['removed']) && $job['removed']) {
- unset($value[$key]);
+ array_splice($value, $key, 1);
}
}
foreach ($value as $key => &$job) {
);
}
}
+
foreach ($value as $key=>&$phone) {
- if (isset($phone['removed']) && $phone['removed']) {
- unset($value[$key]);
- } else {
- unset($phone['removed']);
- $phone['pub'] = $this->pub->value($page, 'pub', $phone['pub'], $s);
- $phone['tel'] = $this->tel->value($page, 'tel', $phone['tel'], $s);
- if(!isset($phone['type']) || ($phone['type'] != 'fixed' && $phone['type'] != 'mobile' && $phone['type'] != 'fax')) {
- $phone['type'] = 'fixed';
- $s = false;
- }
- if (!$s) {
- $phone['error'] = true;
- $success = false;
- }
- if (!isset($phone['comment'])) {
- $phone['comment'] = '';
- }
+ $phone['pub'] = $this->pub->value($page, 'pub', $phone['pub'], $s);
+ $phone['tel'] = $this->tel->value($page, 'tel', $phone['tel'], $s);
+ if(!isset($phone['type']) || ($phone['type'] != 'fixed' && $phone['type'] != 'mobile' && $phone['type'] != 'fax')) {
+ $phone['type'] = 'fixed';
+ $s = false;
+ }
+ if (!$s) {
+ $phone['error'] = true;
+ $success = false;
+ }
+ if (!isset($phone['comment'])) {
+ $phone['comment'] = '';
}
}
+
return $value;
}
<option value="mobile"{if $tel.type eq 'mobile'} selected="selected"{/if}>Mobile</option>
<option value="fax"{if $tel.type eq 'fax'} selected="selected"{/if}>Fax</option>
</select>
- <input type="hidden" name="{$telpref}[removed]" value="0"/>
<input type="text" size="19" maxlength="28" name="{$telpref}[tel]" {if $tel.error}class="error"{/if} value="{$tel.tel}" />
- <a href="javascript:removeTel('{$id}')">
+ <a class="removeTel" href="javascript:removeTel('{$telid}')">
{icon name=cross title="Supprimer ce numéro de téléphone"}
</a>
<a id="{$id}_addComment" href="javascript:addPhoneComment('{$id}')" {if $tel.comment neq ''}style="display:none" {/if}>
<div id="{$id}_comment" style="clear: both;{if $tel.comment eq ''} display:none{/if}">
Commentaire :
<input type="text" size="45" maxlength="80" name="{$telpref}[comment]" {if $tel.error}class="error"{/if} value="{$tel.comment}"/>
- <a href="javascript:removePhoneComment('{$id}','{$telpref}')">
+ <a class="removePhoneComment" href="javascript:removePhoneComment('{$id}','{$telpref}')">
{icon name=cross title="Supprimer le commentaire"}
</a>
</div>